Search in sources :

Example 1 with ImageResourceCell

use of com.google.gwt.cell.client.ImageResourceCell 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)

Example 2 with ImageResourceCell

use of com.google.gwt.cell.client.ImageResourceCell in project rstudio by rstudio.

the class UnsavedChangesDialog method addIconColumn.

private Column<UnsavedChangesTarget, ImageResource> addIconColumn() {
    Column<UnsavedChangesTarget, ImageResource> iconColumn = new Column<UnsavedChangesTarget, ImageResource>(new ImageResourceCell()) {

        @Override
        public ImageResource getValue(UnsavedChangesTarget object) {
            return object.getIcon();
        }
    };
    targetsCellTable_.addColumn(iconColumn);
    targetsCellTable_.setColumnWidth(iconColumn, 20, Unit.PX);
    return iconColumn;
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) IdentityColumn(com.google.gwt.user.cellview.client.IdentityColumn) Column(com.google.gwt.user.cellview.client.Column) UnsavedChangesTarget(org.rstudio.studio.client.workbench.model.UnsavedChangesTarget) ImageResourceCell(com.google.gwt.cell.client.ImageResourceCell)

Example 3 with ImageResourceCell

use of com.google.gwt.cell.client.ImageResourceCell in project rstudio by rstudio.

the class FilesList method addIconColumn.

private Column<FileSystemItem, ImageResource> addIconColumn(final FileTypeRegistry fileTypeRegistry) {
    Column<FileSystemItem, ImageResource> iconColumn = new Column<FileSystemItem, ImageResource>(new ImageResourceCell()) {

        @Override
        public ImageResource getValue(FileSystemItem object) {
            if (object == parentPath_)
                return new ImageResource2x(FileIconResources.INSTANCE.iconUpFolder2x());
            else
                return fileTypeRegistry.getIconForFile(object);
        }
    };
    iconColumn.setSortable(true);
    filesDataGrid_.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    filesDataGrid_.setColumnWidth(iconColumn, ICON_COLUMN_WIDTH_PIXELS, Unit.PX);
    sortHandler_.setComparator(iconColumn, new FilesListComparator() {

        @Override
        public int doCompare(FileSystemItem arg0, FileSystemItem arg1) {
            if (arg0.isDirectory() && !arg1.isDirectory())
                return 1;
            else if (arg1.isDirectory() && !arg0.isDirectory())
                return -1;
            else
                return arg0.getExtension().compareTo(arg1.getExtension());
        }
    });
    return iconColumn;
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ImageResource(com.google.gwt.resources.client.ImageResource) LinkColumn(org.rstudio.core.client.cellview.LinkColumn) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) ImageResourceCell(com.google.gwt.cell.client.ImageResourceCell)

Aggregations

ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)3 ImageResource (com.google.gwt.resources.client.ImageResource)3 Column (com.google.gwt.user.cellview.client.Column)3 SafeHtmlCell (com.google.gwt.cell.client.SafeHtmlCell)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 IdentityColumn (com.google.gwt.user.cellview.client.IdentityColumn)1 TextColumn (com.google.gwt.user.cellview.client.TextColumn)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 LinkColumn (org.rstudio.core.client.cellview.LinkColumn)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 UnsavedChangesTarget (org.rstudio.studio.client.workbench.model.UnsavedChangesTarget)1