Example usage for com.vaadin.ui Grid addColumn

List of usage examples for com.vaadin.ui Grid addColumn

Introduction

In this page you can find the example usage for com.vaadin.ui Grid addColumn.

Prototype

public <V> Column<T, V> addColumn(ValueProvider<T, V> valueProvider) 

Source Link

Document

Adds a new text column to this Grid with a value provider.

Usage

From source file:org.jpos.qi.minigl.TransactionsView.java

License:Open Source License

@Override
public void setGridGetters() {
    Grid<GLTransaction> grid = getGrid();
    grid.addColumn(GLTransaction::getId).setId("id");
    grid.addColumn(GLTransaction::getDetail).setId("detail");
    grid.addColumn(glTransaction -> glTransaction.getJournal().getName()).setId("journal");
    grid.addColumn(glTransaction -> postDateFormat.format(glTransaction.getPostDate())).setId("postDate");
    grid.addColumn(glTransaction -> glTransaction.getTags() != null ? glTransaction.getTags().toString() : "")
            .setId("tags");
    grid.addColumn(GLTransaction::getTimestamp).setId("timestamp");
}

From source file:org.jpos.qi.sysconfig.SysConfigView.java

License:Open Source License

@Override
public void setGridGetters() {
    Grid<SysConfig> g = this.getGrid();
    g.addColumn(sysconfig -> removePrefix(sysconfig.getId())).setId("id");
    g.addColumn(SysConfig::getValue).setId("value");
}

From source file:org.jpos.qi.system.AuditLogView.java

License:Open Source License

@Override
public void setGridGetters() {
    Grid<SysLog> g = getGrid();
    g.addColumn(SysLog::getId).setId("id");
    g.addColumn(SysLog::getDate).setId("date");
    g.addColumn(SysLog::isDeleted).setId("deleted");
    g.addColumn(SysLog::getSource).setId("source");
    g.addColumn(SysLog::getType).setId("type");
    g.addColumn(SysLog::getSeverityAsString).setId("severity");
    g.addColumn(SysLog::getSummary).setId("summary");
    g.addColumn(SysLog::getDetail).setId("detail");
    g.addColumn(SysLog::getTrace).setId("trace");
}

From source file:org.jpos.qi.system.RevisionsView.java

License:Open Source License

@Override
public void setGridGetters() {
    Grid<Revision> g = this.getGrid();
    g.addColumn(Revision::getId).setId("id");
    g.addColumn(Revision::getInfo, new HtmlRenderer("")).setId("info");
    g.addColumn(revision -> ((RevisionsHelper) getHelper()).getLink(revision.getRef(), ""),
            new HtmlRenderer("")).setId("ref");
    g.addColumn(//from  ww  w.  ja va2  s.co m
            revision -> ((RevisionsHelper) getHelper()).getAuthorLink(revision.getAuthor().getNickAndId(), ""),
            new HtmlRenderer("")).setId("author");
    g.addColumn(Revision::getDate).setId("date");

}

From source file:org.openthinclient.web.pkgmngr.ui.InstallationPlanSummaryDialog.java

/**
 * Creates a table with datasource of IndexedContainer
 * @return the Grid for InstallationSummary
 *//*from w w w  .  jav a  2  s  .  co  m*/
private Grid<InstallationSummary> createTable(GridTypes type) {

    Grid<InstallationSummary> summary = new Grid<>();
    summary.setDataProvider(DataProvider.ofCollection(Collections.EMPTY_LIST));
    summary.setSelectionMode(Grid.SelectionMode.NONE);
    summary.addColumn(InstallationSummary::getPackageName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    summary.addColumn(InstallationSummary::getPackageVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    if (type == GridTypes.INSTALL_UNINSTALL && !packageManagerOperation.hasPackagesToUninstall()) { // license column
        summary.addComponentColumn(is -> {
            if (is.getLicense() != null) {
                Button button = new Button(
                        mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                button.addClickListener(click -> {
                    // licence already clicked, re-set button caption
                    licenceButtons.stream().filter(b -> !b.equals(button)).forEach(b -> {
                        if (b.getCaption().equals(
                                mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_HIDE))) {
                            b.setCaption(
                                    mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                        }
                    });
                    // display licence
                    if (button.getCaption()
                            .equals(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW))) {
                        licenceTextArea.setVisible(true);
                        licenceTextArea.setValue(is.getLicense());
                    } else {
                        licenceTextArea.setVisible(false);
                    }
                    button.setCaption(licenceTextArea.isVisible()
                            ? mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_HIDE)
                            : mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE_SHOW));
                });
                button.addStyleName("package_install_summary_display_license_button");
                licenceButtons.add(button);
                return button;
            } else {
                return null;
            }
        }).setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_LICENSE));
    }

    summary.addStyleName(ValoTheme.TABLE_BORDERLESS);
    summary.addStyleName(ValoTheme.TABLE_NO_HEADER);
    summary.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
    summary.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
    summary.setHeightMode(HeightMode.ROW);

    return summary;
}

From source file:org.vaadin.gridfiledownloadertest.GridFileDownloaderUI.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from  w ww .  j a v a  2s  .  com*/
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    final Grid grid = new Grid("Attachment grid");
    grid.setHeightMode(HeightMode.ROW);
    grid.setHeightByRows(5);
    grid.setSelectionMode(SelectionMode.NONE);

    Column column = grid.addColumn("filename");
    column.setHeaderCaption("File name");
    column.setExpandRatio(1);

    Indexed dataSource = grid.getContainerDataSource();
    for (int i = 1; i <= 5; ++i) {
        DownloadPojo cp = new DownloadPojo(i);
        Item item = dataSource.addItem(cp);
        item.getItemProperty("filename").setValue(cp.getName());
    }
    layout.addComponent(grid);
    addGridFileDownloader(grid);

    // set tooltip for the default download column
    grid.setCellDescriptionGenerator(new CellDescriptionGenerator() {

        @Override
        public String getDescription(CellReference cell) {
            if (FontAwesome.DOWNLOAD.equals(cell.getPropertyId())) {
                return "download";
            }
            return null;
        }
    });

    // clear the header
    HeaderCell downloadHeader = grid.getHeaderRow(0).getCell(FontAwesome.DOWNLOAD);
    downloadHeader.setHtml("");
}