Search in sources :

Example 1 with SafeHtmlCell

use of com.google.gwt.cell.client.SafeHtmlCell in project che by eclipse.

the class GithubImporterPageViewImpl method createRepositoriesTable.

/**
     * Creates table what contains list of available repositories.
     *
     * @param resources
     */
private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) {
    repositories = new CellTable<>(15, resources);
    Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(new ImageResourceCell()) {

        @Override
        public ImageResource getValue(ProjectData item) {
            return null;
        }
    };
    Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(final ProjectData item) {
            return SafeHtmlUtils.fromString(item.getName());
        }
    };
    Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(final ProjectData item) {
            return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription() == null ? "" : item.getDescription()).appendHtmlConstant("</span>").toSafeHtml();
        }
    };
    repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);
    repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
    repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());
    // don't show loading indicator
    repositories.setLoadingIndicator(null);
    final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ProjectData selectedObject = selectionModel.getSelectedObject();
            delegate.onRepositorySelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlCell(com.google.gwt.cell.client.SafeHtmlCell) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) ImageResource(com.google.gwt.resources.client.ImageResource) Column(com.google.gwt.user.cellview.client.Column) ImageResourceCell(com.google.gwt.cell.client.ImageResourceCell) ProjectData(org.eclipse.che.plugin.github.ide.load.ProjectData)

Aggregations

ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)1 SafeHtmlCell (com.google.gwt.cell.client.SafeHtmlCell)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Column (com.google.gwt.user.cellview.client.Column)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)1 ProjectData (org.eclipse.che.plugin.github.ide.load.ProjectData)1