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

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

Introduction

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

Prototype

public Column(Cell<C> cell) 

Source Link

Document

Construct a new Column with a given Cell .

Usage

From source file:org.eclipse.che.plugin.artik.ide.updatesdk.UpdateSDKViewImpl.java

License:Open Source License

@Inject
public UpdateSDKViewImpl(UpdateSDKViewImplUiBinder uiBinder, ArtikLocalizationConstant localizationConstants) {
    this.localizationConstants = localizationConstants;
    setTitle(localizationConstants.updateSDKViewTitle());

    targetsTable = new CellTable<>(5, tableResources);

    Column<TargetForUpdate, String> targetColumn = new Column<TargetForUpdate, String>(new TextCell()) {
        @Override/*from  www . j  a v  a2 s . c o  m*/
        public String getValue(TargetForUpdate target) {
            return target.getName();
        }
    };
    Column<TargetForUpdate, String> installedVersionColumn = new Column<TargetForUpdate, String>(
            new TextCell()) {
        @Override
        public String getValue(TargetForUpdate target) {
            return target.getCurrentVersion();
        }
    };

    targetsTable.addColumn(targetColumn, localizationConstants.updateSDKViewColumnTargetTitle());
    targetsTable.setColumnWidth(targetColumn, "60%");
    targetsTable.addColumn(installedVersionColumn,
            localizationConstants.updateSDKViewColumnInstalledVersionTitle());
    targetsTable.setColumnWidth(installedVersionColumn, "40%");

    setWidget(uiBinder.createAndBindUi(this));

    installButton = createButton(localizationConstants.updateSDKViewButtonInstallTitle(),
            "artik-updateSDK-install", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    delegate.onInstallClicked();
                }
            });
    installButton.addStyleName(Window.resources.windowCss().primaryButton());
    addButtonToFooter(installButton);

    cancelButton = createButton(localizationConstants.updateSDKViewButtonCancelTitle(),
            "artik-updateSDK-cancel", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    delegate.onCancelClicked();
                }
            });
    addButtonToFooter(cancelButton);
}

From source file:org.eclipse.che.plugin.docker.ext.client.manage.CredentialsPreferencesViewImpl.java

License:Open Source License

private void initCredentialsTable(CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<AuthConfig, String> serverAddressColumn = new Column<AuthConfig, String>(new TextCell()) {
        @Override// w ww  .ja va2s .  c o m
        public String getValue(AuthConfig object) {
            return object.getServeraddress();
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                    + "preferences-docker-credentials-cellTable-serveraddress-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    serverAddressColumn.setSortable(true);

    Column<AuthConfig, String> editColumn = new Column<AuthConfig, String>(new ButtonCell()) {
        @Override
        public String getValue(AuthConfig object) {
            return "Edit";
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
                sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                        + "preferences-docker-credentials-cellTable-edit-" + context.getIndex() + "\">");
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    editColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() {
        @Override
        public void update(int index, AuthConfig object, String value) {
            delegate.onEditClicked(object);
        }
    });

    Column<AuthConfig, String> deleteColumn = new Column<AuthConfig, String>(new ButtonCell()) {
        @Override
        public String getValue(AuthConfig object) {
            return "Delete";
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
                sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                        + "preferences-docker-credentials-cellTable-delete-" + context.getIndex() + "\">");
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    deleteColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() {
        @Override
        public void update(int index, AuthConfig object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    keys.addColumn(serverAddressColumn, "Server Address");
    keys.addColumn(editColumn, "");//Do not show label for edit column
    keys.addColumn(deleteColumn, "");//Do not show label for delete column
    keys.setColumnWidth(serverAddressColumn, 70, Style.Unit.PCT);
    keys.setColumnWidth(editColumn, 20, Style.Unit.PX);
    keys.setColumnWidth(deleteColumn, 20, Style.Unit.PX);

    // don't show loading indicator
    keys.setLoadingIndicator(null);
}

From source file:org.eclipse.che.plugin.ssh.key.client.manage.SshKeyManagerViewImpl.java

License:Open Source License

/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {
        @Override//from  w  ww.j  a v  a 2s .  com
        public String getValue(SshPairDto object) {
            return object.getName();
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-host-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    hostColumn.setSortable(true);

    Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
        @Override
        public String getValue(SshPairDto object) {
            return "View";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-"
                    + context.getIndex() + "\">");
            if (object != null && object.getPublicKey() != null) {
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onViewClicked(object);
        }
    });

    Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
        @Override
        public String getValue(SshPairDto object) {
            return "Delete";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    // Creates handler on button clicked
    deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    keys.addColumn(hostColumn, "Host");
    keys.addColumn(publicKeyColumn, "Public Key");
    keys.addColumn(deleteKeyColumn, "Delete");
    keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
    keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
    keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);

    // don't show loading indicator
    keys.setLoadingIndicator(null);
}

From source file:org.eclipse.che.plugin.yaml.ide.preferences.YamlExtensionManagerViewImpl.java

License:Open Source License

/**
 * Creates table which contains list of available preferences
 *
 * @param res Celltable resources/* w  ww .j  av a  2  s  . c  o  m*/
 */
private void initYamlExtensionTable(final CellTable.Resources res) {

    yamlPreferenceCellTable = new CellTable<YamlPreference>(20, res);
    Column<YamlPreference, String> urlColumn = new Column<YamlPreference, String>(new EditTextCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return object.getUrl();
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-url-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    urlColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            object.setUrl(value);
            delegate.nowDirty();
        }
    });

    Column<YamlPreference, String> globColumn = new Column<YamlPreference, String>(new EditTextCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return object.getGlob();
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-glob-"
                    + context.getIndex() + "\">");
            if (object != null) {
                super.render(context, object, sb);
            }
        }
    };

    globColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            object.setGlob(value);
            delegate.nowDirty();
        }
    });

    Column<YamlPreference, String> deletePreferenceColumn = new Column<YamlPreference, String>(
            new ButtonCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return "Delete";
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-delete-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    // Creates handler on button clicked
    deletePreferenceColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    yamlPreferenceCellTable.addColumn(urlColumn, local.urlColumnHeader());
    yamlPreferenceCellTable.addColumn(globColumn, local.globColumnHeader());
    yamlPreferenceCellTable.addColumn(deletePreferenceColumn, local.deleteColumnHeader());
    yamlPreferenceCellTable.setWidth("100%", true);
    yamlPreferenceCellTable.setColumnWidth(urlColumn, 45, Style.Unit.PCT);
    yamlPreferenceCellTable.setColumnWidth(globColumn, 30, Style.Unit.PCT);
    yamlPreferenceCellTable.setColumnWidth(deletePreferenceColumn, 25, Style.Unit.PCT);

    // don't show loading indicator
    yamlPreferenceCellTable.setLoadingIndicator(null);
}

From source file:org.eclipse.kura.web.client.ui.Network.TabWirelessUi.java

License:Open Source License

private void initGrid() {

    // CHECKBOXES
    Column<GwtWifiChannelModel, Boolean> checkColumn = new Column<GwtWifiChannelModel, Boolean>(
            new CheckboxCell()) {

        @Override//  ww  w  .j  a v  a 2s .c o  m
        public Boolean getValue(GwtWifiChannelModel object) {
            return TabWirelessUi.this.channelGrid.getSelectionModel().isSelected(object);
        }

    };
    checkColumn.setFieldUpdater(new FieldUpdater<GwtWifiChannelModel, Boolean>() {

        @Override
        public void update(int index, GwtWifiChannelModel object, Boolean value) {
            TabWirelessUi.this.channelGrid.getSelectionModel().setSelected(object, value);
            TabWirelessUi.this.channelDataProvider.refresh();
        }
    });

    checkColumn.setCellStyleNames("status-table-row");
    this.channelGrid.addColumn(checkColumn);

    // ALL AVAILABLE CHANNELS
    TextColumn<GwtWifiChannelModel> col1 = new TextColumn<GwtWifiChannelModel>() {

        @Override
        public String getValue(GwtWifiChannelModel object) {
            return object.getName();
        }
    };
    col1.setCellStyleNames("status-table-row");
    this.channelGrid.addColumn(col1, "All Available Channels");

    // FREQUENCY
    TextColumn<GwtWifiChannelModel> col2 = new TextColumn<GwtWifiChannelModel>() {

        @Override
        public String getValue(GwtWifiChannelModel object) {
            return String.valueOf(object.getFrequency());
        }
    };
    col2.setCellStyleNames("status-table-row");
    this.channelGrid.addColumn(col2, "Frequency (MHz)");

    // SPECTRUM BAND
    TextColumn<GwtWifiChannelModel> col3 = new TextColumn<GwtWifiChannelModel>() {

        @Override
        public String getValue(GwtWifiChannelModel object) {
            return String.valueOf(object.getBand());
        }
    };
    col3.setCellStyleNames("status-table-row");
    this.channelGrid.addColumn(col3, "Frequency (MHz)");

    this.channelGrid.setSelectionModel(this.selectionModel);
    this.channelDataProvider.addDataDisplay(this.channelGrid);

    loadChannelData();
}

From source file:org.eclipse.kura.web.client.ui.Status.StatusPanelUi.java

License:Open Source License

public void loadStatusTable(CellTable<GwtGroupedNVPair> grid, ListDataProvider<GwtGroupedNVPair> dataProvider) {
    TextColumn<GwtGroupedNVPair> col1 = new TextColumn<GwtGroupedNVPair>() {

        @Override//from w  ww.  j a  va2s. co  m
        public String getValue(GwtGroupedNVPair object) {
            return String.valueOf(object.getName());
        }
    };
    col1.setCellStyleNames("status-table-row");
    grid.addColumn(col1);

    Column<GwtGroupedNVPair, SafeHtml> col2 = new Column<GwtGroupedNVPair, SafeHtml>(new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(GwtGroupedNVPair object) {
            return SafeHtmlUtils.fromTrustedString(String.valueOf(object.getValue()));
        }
    };

    col2.setCellStyleNames("status-table-row");
    grid.addColumn(col2);
    dataProvider.addDataDisplay(grid);
}

From source file:org.glom.web.client.ui.list.ListTable.java

License:Open Source License

private void addColumn(final LayoutItemField layoutItemField) {
    // Setup the default alignment of the column.
    HorizontalAlignmentConstant columnAlignment;
    Formatting formatting = layoutItemField.getFormatting();
    if (formatting == null) {
        GWT.log("addColumn(): Formatting is null for field=" + layoutItemField.getLayoutDisplayName());
        formatting = new Formatting(); // Just to avoid null dereferencing later.
    }/*from www . j a v  a2 s .  co m*/

    switch (formatting.getHorizontalAlignment()) {
    case HORIZONTAL_ALIGNMENT_LEFT:
        columnAlignment = HasHorizontalAlignment.ALIGN_LEFT;
        break;
    case HORIZONTAL_ALIGNMENT_RIGHT:
        columnAlignment = HasHorizontalAlignment.ALIGN_RIGHT;
        break;
    case HORIZONTAL_ALIGNMENT_AUTO:
    default:
        columnAlignment = HasHorizontalAlignment.ALIGN_DEFAULT;
        break;
    }

    // create a new column
    Column<DataItem[], ?> column = null;
    final int j = cellTable.getColumnCount();
    switch (layoutItemField.getGlomType()) {

    case TYPE_BOOLEAN:
        column = new Column<DataItem[], Boolean>(new BooleanCell()) {
            @Override
            public Boolean getValue(final DataItem[] row) {
                if (row.length == 1 && row[0] == null) {
                    // an empty row
                    return null;
                }

                if (j >= row.length) {
                    GWT.log("addColumn(): j=" + j + " is out of range. length=" + row.length);
                    return null;
                } else {
                    return row[j].getBoolean();
                }
            }
        };
        // override the configured horizontal alignment
        columnAlignment = HasHorizontalAlignment.ALIGN_CENTER;
        break;

    case TYPE_NUMERIC:
        // create a GWT NumberFormat for the column
        final NumericFormat numericFormat = formatting.getNumericFormat();
        final NumberFormat gwtNumberFormat = Utils.getNumberFormat(numericFormat);

        // create the actual column
        column = new Column<DataItem[], Double>(new NumericCell(
                formatting.getTextFormatColorForegroundAsHTMLColor(),
                formatting.getTextFormatColorBackgroundAsHTMLColor(), gwtNumberFormat,
                numericFormat.getUseAltForegroundColorForNegatives(), numericFormat.getCurrencySymbol())) {
            @Override
            public Double getValue(final DataItem[] row) {
                if (row.length == 1 && row[0] == null) {
                    // an empty row
                    return null;
                }

                if (j >= row.length) {
                    GWT.log("addColumn(): j=" + j + " is out of range. length=" + row.length);
                    return null;
                } else {
                    return row[j].getNumber();
                }
            }
        };
        break;
    case TYPE_IMAGE:
        column = new Column<DataItem[], String>(new ImageCell()) {
            @Override
            public String getValue(final DataItem[] row) {
                if (row.length == 1 && row[0] == null) {
                    // an empty row
                    return null;
                }

                if (j >= row.length) {
                    GWT.log("addColumn(): j=" + j + " is out of range. length=" + row.length);
                    return null;
                } else {
                    return row[j].getImageDataUrl();
                }
            }
        };
        // override the configured horizontal alignment
        columnAlignment = HasHorizontalAlignment.ALIGN_CENTER;
        break;

    default:
        // use a text rendering cell for types we don't know about but log an error
        // TODO log error here
    case TYPE_DATE:
    case TYPE_INVALID:
    case TYPE_TIME:
    case TYPE_TEXT:
        column = new Column<DataItem[], String>(
                new TextCell(formatting.getTextFormatColorForegroundAsHTMLColor(),
                        formatting.getTextFormatColorBackgroundAsHTMLColor())) {
            @Override
            public String getValue(final DataItem[] row) {
                if (row.length == 1 && row[0] == null) {
                    // an empty row
                    return null;
                }

                if (j >= row.length) {
                    GWT.log("addColumn(): j=" + j + " is out of range. length=" + row.length);
                    return null;
                } else {
                    return row[j].getText();
                }
            }
        };
        break;
    }

    // set column properties and add to cell cellTable
    column.setHorizontalAlignment(columnAlignment);
    column.setSortable(true);
    cellTable.addColumn(column, new SafeHtmlHeader(SafeHtmlUtils.fromString(layoutItemField.getTitle())));
}

From source file:org.glom.web.client.ui.list.ListTable.java

License:Open Source License

private void addNavigationButtonColumn(final String navigationButtonLabel,
        final NavigationButtonCell navigationButtonCell) {

    navigationButtonColumn = new Column<DataItem[], String>(navigationButtonCell) {
        @Override/*from   ww  w  . j ava 2s. c  om*/
        public String getValue(final DataItem[] row) {
            if (row.length == 1 && row[0] == null) {
                // an empty row
                return null;
            }
            return navigationButtonLabel;
        }
    };

    // Firefox, Chrome, and Safari only support the span and width attributes of the col element so we need to set
    // the alignment with code
    navigationButtonColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    cellTable.addColumn(navigationButtonColumn, "");

    // the style name for the details column is set on the col element
    cellTable.addColumnStyleName(cellTable.getColumnCount() - 1, "details");

}

From source file:org.guvnor.ala.ui.client.widget.artifact.ArtifactSelectorView.java

License:Apache License

private Column<JarListPageRow, String> buildSelectColumn() {
    return new Column<JarListPageRow, String>(new ButtonCell(ButtonSize.EXTRA_SMALL)) {
        public String getValue(final JarListPageRow row) {
            return getSelectColumnLabel();
        }//  ww w  . j  av a  2s  . c  om

        {
            setFieldUpdater(new FieldUpdater<JarListPageRow, String>() {
                public void update(final int index, final JarListPageRow row, final String value) {
                    presenter.onArtifactSelected(row.getPath());
                }
            });
        }
    };
}

From source file:org.guvnor.ala.ui.client.wizard.container.ContainerConfigParamsView.java

License:Apache License

private void addNameColumn() {
    Column<ContainerConfig, String> column = new Column<ContainerConfig, String>(new TextCell()) {
        @Override/*  w ww .j a  v  a  2 s . c  o  m*/
        public String getValue(ContainerConfig containerConfig) {
            return containerConfig.getName();
        }
    };

    dataGrid.addColumn(column,
            translationService.getTranslation(ContainerConfigParamsView_ContainerNameColumn));
}