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.kie.workbench.common.screens.datamodeller.client.widgets.DataModelBrowser.java

License:Apache License

public DataModelBrowser() {
    initWidget(uiBinder.createAndBindUi(this));

    modelName.setText(Constants.INSTANCE.modelBrowser_modelUnknown());

    dataObjectsProvider.setList(dataObjects);
    dataObjectsTable.setEmptyTableWidget(
            new com.github.gwtbootstrap.client.ui.Label(Constants.INSTANCE.modelBrowser_emptyTable()));

    // Init delete column
    ClickableImageResourceCell clickableImageResourceCell = new ClickableImageResourceCell(true);
    final TooltipCellDecorator<ImageResource> decorator = new TooltipCellDecorator<ImageResource>(
            clickableImageResourceCell);
    decorator.setText(Constants.INSTANCE.modelBrowser_action_deleteDataObject());

    final Column<DataObjectTO, ImageResource> deleteDataObjectColumnImg = new Column<DataObjectTO, ImageResource>(
            decorator) {//ww w  .j  a  va  2s  . c  om
        @Override
        public ImageResource getValue(final DataObjectTO global) {
            return ImagesResources.INSTANCE.Delete();
        }
    };

    deleteDataObjectColumnImg.setFieldUpdater(new FieldUpdater<DataObjectTO, ImageResource>() {
        public void update(final int index, final DataObjectTO object, final ImageResource value) {
            deleteDataObject(object, index);
        }
    });

    dataObjectsTable.addColumn(deleteDataObjectColumnImg);
    dataObjectsTable.setColumnWidth(deleteDataObjectColumnImg, 20, Style.Unit.PX);

    // Init data object column
    final TextColumn<DataObjectTO> dataObjectColumn = new TextColumn<DataObjectTO>() {

        @Override
        public void render(Cell.Context context, DataObjectTO object, SafeHtmlBuilder sb) {
            SafeHtml startDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                }
            };
            SafeHtml endDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "</div>";
                }
            };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
        }

        @Override
        public String getValue(final DataObjectTO dataObject) {
            return DataModelerUtils.getDataObjectUILabel(dataObject);
        }
    };
    dataObjectColumn.setSortable(true);
    dataObjectsTable.addColumn(dataObjectColumn, Constants.INSTANCE.modelBrowser_columnName());

    ColumnSortEvent.ListHandler<DataObjectTO> dataObjectNameColHandler = new ColumnSortEvent.ListHandler<DataObjectTO>(
            dataObjectsProvider.getList());
    dataObjectNameColHandler.setComparator(dataObjectColumn, new DataObjectComparator());
    dataObjectsTable.addColumnSortHandler(dataObjectNameColHandler);
    dataObjectsTable.getColumnSortList().push(dataObjectColumn);

    //Init the selection model
    SingleSelectionModel<DataObjectTO> selectionModel = new SingleSelectionModel<DataObjectTO>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            if (!skipNextOnChange) {
                DataObjectTO selectedObjectTO = ((SingleSelectionModel<DataObjectTO>) dataObjectsTable
                        .getSelectionModel()).getSelectedObject();
                notifyObjectSelected(selectedObjectTO);
            }
            skipNextOnChange = false;
        }
    });

    dataObjectsTable
            .setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    dataObjectsTable.setSelectionModel(selectionModel);

    dataObjectsProvider.addDataDisplay(dataObjectsTable);
    dataObjectsProvider.refresh();

    newEntityButton.setIcon(IconType.PLUS_SIGN);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.DataObjectBrowser.java

License:Apache License

public DataObjectBrowser() {
    initWidget(uiBinder.createAndBindUi(this));

    objectButton.setType(ButtonType.LINK);
    objectButton.addClickHandler(new ClickHandler() {
        @Override//from  w ww . j av a  2s . c o  m
        public void onClick(ClickEvent event) {
            lastSelectedRow = dataObjectPropertiesTable.getKeyboardSelectedRow();
            showingObject = true;
            ObjectProperty currentSelection = ((SingleSelectionModel<ObjectProperty>) dataObjectPropertiesTable
                    .getSelectionModel()).getSelectedObject();
            if (currentSelection != null) {
                dataObjectPropertiesTable.getSelectionModel().setSelected(currentSelection, false);
            }
            notifyObjectSelected();
        }
    });

    dataObjectPropertiesProvider.setList(new ArrayList<ObjectProperty>());

    //Init data objects table

    dataObjectPropertiesTable.setEmptyTableWidget(
            new com.github.gwtbootstrap.client.ui.Label(Constants.INSTANCE.objectBrowser_emptyTable()));

    //Init property name column

    final TextColumn<ObjectProperty> propertyNameColumn = new TextColumn<ObjectProperty>() {

        @Override
        public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                }
            };
            SafeHtml endDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "</div>";
                }
            };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
        }

        @Override
        public String getValue(final ObjectProperty objectProperty) {
            return objectProperty.getName();
        }
    };

    propertyNameColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(propertyNameColumn, Constants.INSTANCE.objectBrowser_columnName());
    //dataObjectPropertiesTable.setColumnWidth(propertyNameColumn, 100, Style.Unit.PX);
    dataObjectPropertiesTable.setColumnWidth(propertyNameColumn, 30, Style.Unit.PCT);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyNameColHandler = new ColumnSortEvent.ListHandler<ObjectProperty>(
            dataObjectPropertiesProvider.getList());
    propertyNameColHandler.setComparator(propertyNameColumn, new ObjectPropertyComparator("name"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyNameColHandler);

    //Init property Label column

    final TextColumn<ObjectProperty> propertyLabelColumn = new TextColumn<ObjectProperty>() {

        @Override
        public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                }
            };
            SafeHtml endDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "</div>";
                }
            };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
        }

        @Override
        public String getValue(final ObjectProperty objectProperty) {
            return AnnotationValueHandler.getStringValue(objectProperty, MainDomainAnnotations.LABEL_ANNOTATION,
                    MainDomainAnnotations.VALUE_PARAM);
        }
    };

    propertyLabelColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(propertyLabelColumn, Constants.INSTANCE.objectBrowser_columnLabel());
    dataObjectPropertiesTable.setColumnWidth(propertyLabelColumn, 30, Style.Unit.PCT);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyLabelColHandler = new ColumnSortEvent.ListHandler<ObjectProperty>(
            dataObjectPropertiesProvider.getList());
    propertyNameColHandler.setComparator(propertyLabelColumn, new ObjectPropertyComparator("label"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyLabelColHandler);

    //Init property type browsing column
    ClickableImageResourceCell typeImageCell = new ClickableImageResourceCell(true, 25);
    final TooltipCellDecorator<ImageResource> typeImageDecorator = new TooltipCellDecorator<ImageResource>(
            typeImageCell);
    typeImageDecorator.setText(Constants.INSTANCE.objectBrowser_action_goToDataObjectDefinition());

    final Column<ObjectProperty, ImageResource> typeImageColumn = new Column<ObjectProperty, ImageResource>(
            typeImageDecorator) {
        @Override
        public ImageResource getValue(final ObjectProperty property) {

            if (!property.isBaseType() && !getDataObject().getClassName().equals(property.getClassName())
                    && !getDataModel().isExternal(property.getClassName())) {
                return ImagesResources.INSTANCE.BrowseObject();
            } else {
                return null;
            }
        }
    };

    typeImageColumn.setFieldUpdater(new FieldUpdater<ObjectProperty, ImageResource>() {
        public void update(final int index, final ObjectProperty property, final ImageResource value) {

            onTypeCellSelection(property);
        }
    });

    dataObjectPropertiesTable.addColumn(typeImageColumn);

    //Init property type column
    final TextColumn<ObjectProperty> propertyTypeColumn = new TextColumn<ObjectProperty>() {

        @Override
        public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                }
            };
            SafeHtml endDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "</div>";
                }
            };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
        }

        @Override
        public String getValue(final ObjectProperty objectProperty) {
            return propertyTypeDisplay(objectProperty);
        }
    };
    propertyTypeColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(propertyTypeColumn, Constants.INSTANCE.objectBrowser_columnType());
    dataObjectPropertiesTable.setColumnWidth(propertyTypeColumn, 40, Style.Unit.PCT);

    //Init delete column
    ClickableImageResourceCell deleteImageCell = new ClickableImageResourceCell(true, 25);
    final TooltipCellDecorator<ImageResource> decorator = new TooltipCellDecorator<ImageResource>(
            deleteImageCell);
    decorator.setPlacement(Placement.LEFT);
    decorator.setText(Constants.INSTANCE.objectBrowser_action_deleteProperty());

    final Column<ObjectProperty, ImageResource> deletePropertyColumnImg = new Column<ObjectProperty, ImageResource>(
            decorator) {
        @Override
        public ImageResource getValue(final ObjectProperty global) {
            if (!isReadonly()) {
                return ImagesResources.INSTANCE.Delete();
            } else {
                return null;
            }
        }
    };

    deletePropertyColumnImg.setFieldUpdater(new FieldUpdater<ObjectProperty, ImageResource>() {
        public void update(final int index, final ObjectProperty property, final ImageResource value) {

            if (!isReadonly()) {
                checkAndDeleteDataObjectProperty(property, index);
            }
        }
    });

    dataObjectPropertiesTable.addColumn(deletePropertyColumnImg);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyTypeColHandler = new ColumnSortEvent.ListHandler<ObjectProperty>(
            dataObjectPropertiesProvider.getList());
    propertyTypeColHandler.setComparator(propertyTypeColumn, new ObjectPropertyComparator("className"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyTypeColHandler);

    dataObjectPropertiesTable.getColumnSortList().push(propertyNameColumn);

    //Init the selection model
    SingleSelectionModel<ObjectProperty> selectionModel = new SingleSelectionModel<ObjectProperty>();
    dataObjectPropertiesTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ObjectProperty selectedProperty = ((SingleSelectionModel<ObjectProperty>) dataObjectPropertiesTable
                    .getSelectionModel()).getSelectedObject();
            notifyFieldSelected(selectedProperty);
        }
    });

    dataObjectPropertiesTable
            .setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.BOUND_TO_SELECTION);

    dataObjectPropertiesTable.addCellPreviewHandler(new CellPreviewEvent.Handler<ObjectProperty>() {

        @Override
        public void onCellPreview(CellPreviewEvent<ObjectProperty> event) {
            if (showingObject && "click".equals(event.getNativeEvent().getType())) {
                int selectedRow = dataObjectPropertiesTable.getKeyboardSelectedRow();
                if (lastSelectedRow >= 0 && lastSelectedRow == selectedRow) {
                    ObjectProperty selectedProperty = dataObjectPropertiesProvider.getList().get(selectedRow);
                    ((SingleSelectionModel<ObjectProperty>) dataObjectPropertiesTable.getSelectionModel())
                            .setSelected(selectedProperty, true);
                }
                showingObject = false;
            }
        }
    });

    dataObjectPropertiesProvider.addDataDisplay(dataObjectPropertiesTable);
    dataObjectPropertiesProvider.refresh();

    newPropertyButton.setIcon(IconType.PLUS_SIGN);

    setReadonly(true);

}

From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.editor.DataObjectBrowserViewImpl.java

License:Apache License

private void addPropertyTypeColumn() {
    Column<ObjectProperty, HyperLinkCell.HyperLink> column = new Column<ObjectProperty, HyperLinkCell.HyperLink>(
            new HyperLinkCell()) {

        @Override/*from   w w w  . j ava2s  .  com*/
        public HyperLinkCell.HyperLink getValue(ObjectProperty objectProperty) {
            if (presenter != null && objectProperty.getName() != null) {
                final String textValue = presenter.getPropertyTypeDisplayValue(objectProperty);
                if (presenter.isSelectablePropertyType(objectProperty)) {
                    return HyperLinkCell.HyperLink.newLink(textValue);
                } else {
                    return HyperLinkCell.HyperLink.newText(textValue);
                }
            } else {
                return HyperLinkCell.HyperLink.newText("");
            }
        }
    };

    column.setFieldUpdater((index, objectProperty, value) -> {
        if (presenter != null && presenter.isSelectablePropertyType(objectProperty)) {
            presenter.onSelectPropertyType(objectProperty);
        }
    });

    column.setSortable(true);
    propertiesTable.addColumn(column, Constants.INSTANCE.objectBrowser_columnType());
    propertiesTable.setColumnWidth(column, 35, Style.Unit.PCT);
    columnIds.put(column, ColumnId.TYPE_COLUMN);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.editor.DataObjectBrowserViewImpl.java

License:Apache License

private void addRemoveRowColumn() {
    ButtonCell buttonCell = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL);
    Column<ObjectProperty, String> column = new Column<ObjectProperty, String>(buttonCell) {
        @Override//from  w w w . j ava  2  s. c  o m
        public String getValue(ObjectProperty objectProperty) {
            return Constants.INSTANCE.objectBrowser_action_delete();
        }
    };

    column.setFieldUpdater(new FieldUpdater<ObjectProperty, String>() {
        @Override
        public void update(int index, ObjectProperty objectProperty, String value) {

            if (!readonly) {
                presenter.onDeleteProperty(objectProperty, index);
            }
        }
    });

    propertiesTable.addColumn(column, "");
    propertiesTable.setColumnWidth(column,
            calculateButtonSize(Constants.INSTANCE.objectBrowser_action_delete()), Style.Unit.PX);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.old.DataModelBrowser.java

License:Apache License

public DataModelBrowser() {
    initWidget(uiBinder.createAndBindUi(this));

    //modelName.setText( Constants.INSTANCE.modelBrowser_modelUnknown() );

    dataObjectsProvider.setList(dataObjects);
    dataObjectsTable.setEmptyTableWidget(
            new com.github.gwtbootstrap.client.ui.Label(Constants.INSTANCE.modelBrowser_emptyTable()));

    // Init data object column
    final TextColumn<DataObject> dataObjectColumn = new TextColumn<DataObject>() {

        @Override/*from   w ww .  ja va2s. c o m*/
        public void render(Cell.Context context, DataObject object, SafeHtmlBuilder sb) {
            SafeHtml startDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                }
            };
            SafeHtml endDiv = new SafeHtml() {
                @Override
                public String asString() {
                    return "</div>";
                }
            };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
        }

        @Override
        public String getValue(final DataObject dataObject) {
            // TODO return clipped AND tooltipped object UI label when relevant
            return DataModelerUtils.getDataObjectUILabel(dataObject);
        }
    };
    dataObjectColumn.setSortable(true);
    dataObjectsTable.addColumn(dataObjectColumn, Constants.INSTANCE.modelBrowser_columnName());

    // Init delete column
    ClickableImageResourceCell clickableImageResourceCell = new ClickableImageResourceCell(true, 16);
    final TooltipCellDecorator<ImageResource> decorator = new TooltipCellDecorator<ImageResource>(
            clickableImageResourceCell);
    decorator.setPlacement(Placement.LEFT);
    decorator.setText(Constants.INSTANCE.modelBrowser_action_deleteDataObject());

    final Column<DataObject, ImageResource> deleteDataObjectColumnImg = new Column<DataObject, ImageResource>(
            decorator) {
        @Override
        public ImageResource getValue(final DataObject dataObject) {
            return ImagesResources.INSTANCE.Delete();
        }
    };

    deleteDataObjectColumnImg.setFieldUpdater(new FieldUpdater<DataObject, ImageResource>() {
        public void update(final int index, final DataObject object, final ImageResource value) {
            checkAndDeleteDataObject(object, index);
        }
    });

    dataObjectsTable.addColumn(deleteDataObjectColumnImg);
    dataObjectsTable.setColumnWidth(deleteDataObjectColumnImg, 32, Style.Unit.PX);

    ColumnSortEvent.ListHandler<DataObject> dataObjectNameColHandler = new ColumnSortEvent.ListHandler<DataObject>(
            dataObjectsProvider.getList());
    dataObjectNameColHandler.setComparator(dataObjectColumn, new DataObjectComparator());
    dataObjectsTable.addColumnSortHandler(dataObjectNameColHandler);
    dataObjectsTable.getColumnSortList().push(dataObjectColumn);

    //Init the selection model
    SingleSelectionModel<DataObject> selectionModel = new SingleSelectionModel<DataObject>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            if (!skipNextOnChange) {
                DataObject selectedObject = ((SingleSelectionModel<DataObject>) dataObjectsTable
                        .getSelectionModel()).getSelectedObject();
                notifyObjectSelected(selectedObject);
            }
            skipNextOnChange = false;
        }
    });

    dataObjectsTable
            .setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    dataObjectsTable.setSelectionModel(selectionModel);

    dataObjectsProvider.addDataDisplay(dataObjectsTable);
    dataObjectsProvider.refresh();

    newEntityButton.setIcon(IconType.PLUS_SIGN);
}

From source file:org.kie.workbench.common.screens.datasource.management.client.dbexplorer.dbobjects.DatabaseObjectExplorerViewImpl.java

License:Apache License

private void addOpenColumn() {
    Column<DatabaseObjectRow, String> column = new Column<DatabaseObjectRow, String>(
            new ButtonCell(ButtonType.DEFAULT, ButtonSize.SMALL)) {
        @Override//from w w w.j  a v a  2 s .  co m
        public String getValue(DatabaseObjectRow row) {
            return translationService
                    .getTranslation(DataSourceManagementConstants.DatabaseObjectExplorerViewImpl_dbObjectOpen);
        }
    };
    column.setFieldUpdater(new FieldUpdater<DatabaseObjectRow, String>() {
        @Override
        public void update(int index, DatabaseObjectRow row, String value) {
            onOpen(row);
        }
    });
    dataGrid.addColumn(column, translationService
            .getTranslation(DataSourceManagementConstants.DatabaseObjectExplorerViewImpl_dbObjectActionColumn));
    dataGrid.setColumnWidth(column, 10, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.datasource.management.client.dbexplorer.schemas.DatabaseSchemaExplorerViewImpl.java

License:Apache License

private void addOpenColumn() {
    Column<DatabaseSchemaRow, String> column = new Column<DatabaseSchemaRow, String>(
            new ButtonCell(ButtonType.DEFAULT, ButtonSize.SMALL)) {
        @Override//  w w  w .ja va2  s . c  om
        public String getValue(DatabaseSchemaRow row) {
            return translationService.getTranslation(
                    DataSourceManagementConstants.DatabaseSchemaExplorerViewImpl_schemaOpenAction);
        }
    };
    column.setFieldUpdater(new FieldUpdater<DatabaseSchemaRow, String>() {
        @Override
        public void update(int index, DatabaseSchemaRow row, String value) {
            onOpen(row);
        }
    });
    dataGrid.addColumn(column, translationService
            .getTranslation(DataSourceManagementConstants.DatabaseSchemaExplorerViewImpl_actionColumn));
    dataGrid.setColumnWidth(column, 10, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.datasource.management.client.editor.datasource.selector.DataSourceSelectorViewImpl.java

License:Apache License

@PostConstruct
private void init() {
    dataGrid.setHeight("200px");
    dataGrid.setColumnPickerButtonVisible(false);
    dataGrid.setEmptyTableCaption(translationService
            .getTranslation(DataSourceManagementConstants.DataSourceSelector_NoAvailableDataSourcesMessage));

    Column<DataSourceSelectorPageRow, String> nameColumn = new Column<DataSourceSelectorPageRow, String>(
            new TextCell()) {
        @Override//from  w  w  w  . j  a  v a2 s .  com
        public String getValue(DataSourceSelectorPageRow row) {
            return row.getDataSourceDefInfo().getName();
        }
    };
    dataGrid.addColumn(nameColumn, translationService
            .getTranslation(DataSourceManagementConstants.DataSourceSelector_DataSourceColumn));

    Column<DataSourceSelectorPageRow, String> selectorColumn = new Column<DataSourceSelectorPageRow, String>(
            new ButtonCell(ButtonType.PRIMARY, ButtonSize.SMALL)) {
        @Override
        public String getValue(DataSourceSelectorPageRow row) {
            return translationService
                    .getTranslation(DataSourceManagementConstants.DataSourceSelector_SelectButton);
        }
    };

    selectorColumn.setFieldUpdater(new FieldUpdater<DataSourceSelectorPageRow, String>() {
        @Override
        public void update(int index, DataSourceSelectorPageRow row, String value) {
            selectedRow = row;
            cancelNextHiddenEvent = true;
            modal.hide();
            presenter.onSelect();
        }
    });
    dataGrid.addColumn(selectorColumn, "");

    mainPanel.add(dataGrid);

    this.modal = new BaseModal();
    this.modal.setTitle(
            translationService.getTranslation(DataSourceManagementConstants.DataSourceSelector_Title));
    this.modal.setBody(this);
    this.modal.addHiddenHandler(new ModalHiddenHandler() {
        @Override
        public void onHidden(ModalHiddenEvent evt) {
            if (!cancelNextHiddenEvent) {
                presenter.onClose();
            }
            cancelNextHiddenEvent = false;
        }
    });
}

From source file:org.kie.workbench.common.screens.messageconsole.client.console.MessageConsoleViewImpl.java

License:Apache License

private void addFileNameColumn() {
    Column<MessageConsoleServiceRow, String> column = new Column<MessageConsoleServiceRow, String>(
            new ClickableTextCell()) {
        @Override//from  ww  w .  j a v a 2s . c  om
        public String getValue(MessageConsoleServiceRow row) {
            if (row.getMessagePath() != null) {
                return row.getMessagePath().getFileName();
            } else {
                return "-";
            }
        }
    };
    column.setFieldUpdater(new FieldUpdater<MessageConsoleServiceRow, String>() {
        @Override
        public void update(int index, MessageConsoleServiceRow row, String value) {
            if (row.getMessagePath() != null) {
                placeManager.goTo(row.getMessagePath());
            }
        }
    });
    dataGrid.addColumn(column, MessageConsoleResources.CONSTANTS.FileName());
    dataGrid.setColumnWidth(column, 60, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.dependencies.DependencyListWidget.java

License:Apache License

@PostConstruct
public void init() {
    dependencyPagedJarTable = IOC.getBeanManager().lookupBean(ArtifactListPresenter.class).getInstance();

    dependencyPagedJarTable.setup(ColumnType.NAME, ColumnType.GAV, ColumnType.LAST_MODIFIED);

    // Column to view KJAR's pom
    final Column<JarListPageRow, String> openColumn = new Column<JarListPageRow, String>(
            new ButtonCell(ButtonSize.EXTRA_SMALL)) {
        @Override// w w  w  . jav  a2  s  .  c  om
        public String getValue(JarListPageRow row) {
            return M2RepoEditorConstants.INSTANCE.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<JarListPageRow, String>() {
        @Override
        public void update(int index, JarListPageRow row, String value) {
            dependencyPagedJarTable.onOpenPom(row.getPath());
        }
    });

    // Column to allow selection of dependency
    final Column<JarListPageRow, String> selectColumn = new Column<JarListPageRow, String>(
            new ButtonCell(ButtonSize.EXTRA_SMALL)) {
        @Override
        public String getValue(JarListPageRow row) {
            return ProjectEditorResources.CONSTANTS.Select();
        }
    };
    selectColumn.setFieldUpdater(new FieldUpdater<JarListPageRow, String>() {
        @Override
        public void update(final int index, final JarListPageRow row, final String value) {
            onPathSelect.execute(row.getPath());
        }
    });
    final ArtifactListView artifactListView = dependencyPagedJarTable.getView();

    artifactListView.addColumn(openColumn, M2RepoEditorConstants.INSTANCE.Open(), false, 100.0, Style.Unit.PX);
    artifactListView.addColumn(selectColumn, ProjectEditorResources.CONSTANTS.Select(), 100.0, Style.Unit.PX);
    artifactListView.setContentHeight("200px");
    artifactListView.asWidget().getElement().getStyle().setMarginLeft(0, Style.Unit.PX);
    artifactListView.asWidget().getElement().getStyle().setMarginRight(0, Style.Unit.PX);

    panel.add(artifactListView);
}