Search in sources :

Example 1 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class SshKeyManagerViewImpl method initSshKeyTable.

/** 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
        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);
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) Column(com.google.gwt.user.cellview.client.Column) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ButtonCell(com.google.gwt.cell.client.ButtonCell) TextCell(com.google.gwt.cell.client.TextCell)

Example 2 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class ResetFilesViewImpl method initColumns.

/** Initialize the columns of the grid. */
private void initColumns() {
    indexFiles = new CellTable<IndexFile>();
    // Create files column:
    Column<IndexFile, String> filesColumn = new Column<IndexFile, String>(new TextCell()) {

        @Override
        public String getValue(IndexFile file) {
            return file.getPath();
        }
    };
    // Create column with checkboxes:
    Column<IndexFile, Boolean> checkColumn = new Column<IndexFile, Boolean>(new CheckboxCell(false, true)) {

        @Override
        public Boolean getValue(IndexFile file) {
            return !file.isIndexed();
        }
    };
    // Create bean value updater:
    FieldUpdater<IndexFile, Boolean> checkFieldUpdater = new FieldUpdater<IndexFile, Boolean>() {

        @Override
        public void update(int index, IndexFile file, Boolean value) {
            file.setIndexed(!value);
        }
    };
    checkColumn.setFieldUpdater(checkFieldUpdater);
    filesColumn.setHorizontalAlignment(ALIGN_LEFT);
    indexFiles.addColumn(checkColumn, new SafeHtml() {

        @Override
        public String asString() {
            return "&nbsp;";
        }
    });
    indexFiles.setColumnWidth(checkColumn, 1, Style.Unit.PCT);
    indexFiles.addColumn(filesColumn, FILES);
    indexFiles.setColumnWidth(filesColumn, 35, Style.Unit.PCT);
    indexFiles.addStyleName(resources.gitCSS().cells());
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) IndexFile(org.eclipse.che.api.git.shared.IndexFile) TextCell(com.google.gwt.cell.client.TextCell) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell)

Example 3 with Column

use of com.google.gwt.user.cellview.client.Column 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 4 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class SshKeyManagerViewImpl method initSshKeyTable.

/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
    keys = new CellTable<>(20, res);
    Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {

        @Override
        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-title-" + 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, "Title");
    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);
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) Column(com.google.gwt.user.cellview.client.Column) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ButtonCell(com.google.gwt.cell.client.ButtonCell) TextCell(com.google.gwt.cell.client.TextCell)

Example 5 with Column

use of com.google.gwt.user.cellview.client.Column in project rstudio by rstudio.

the class PackagesPane method initPackagesTable.

private void initPackagesTable() {
    packagesTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    packagesTable_.setSelectionModel(new NoSelectionModel<PackageInfo>());
    LoadedColumn loadedColumn = new LoadedColumn();
    NameColumn nameColumn = new NameColumn();
    Column<PackageInfo, PackageInfo> descColumn = new Column<PackageInfo, PackageInfo>(new DescriptionCell()) {

        @Override
        public PackageInfo getValue(PackageInfo object) {
            return object;
        }
    };
    Column<PackageInfo, PackageInfo> versionColumn = new Column<PackageInfo, PackageInfo>(new VersionCell(false)) {

        @Override
        public PackageInfo getValue(PackageInfo object) {
            return object;
        }
    };
    ImageButtonColumn<PackageInfo> removeColumn = new ImageButtonColumn<PackageInfo>(new ImageResource2x(ThemeResources.INSTANCE.removePackage2x()), new OperationWithInput<PackageInfo>() {

        @Override
        public void execute(PackageInfo packageInfo) {
            observer_.removePackage(packageInfo);
        }
    }, "Remove package");
    // add common columns
    packagesTable_.addColumn(loadedColumn, new TextHeader(""));
    packagesTable_.addColumn(nameColumn, new TextHeader("Name"));
    packagesTable_.addColumn(descColumn, new TextHeader("Description"));
    packagesTable_.addColumn(versionColumn, new TextHeader("Version"));
    packagesTable_.setColumnWidth(loadedColumn, 30, Unit.PX);
    // set up Packrat-specific columns
    if (packratContext_ != null && packratContext_.isModeOn()) {
        Column<PackageInfo, PackageInfo> packratVersionColumn = new Column<PackageInfo, PackageInfo>(new VersionCell(true)) {

            @Override
            public PackageInfo getValue(PackageInfo object) {
                return object;
            }
        };
        TextColumn<PackageInfo> packratSourceColumn = new TextColumn<PackageInfo>() {

            @Override
            public String getValue(PackageInfo pkgInfo) {
                if (pkgInfo.getInPackratLibary()) {
                    String source = pkgInfo.getPackratSource();
                    if (source.equals("github"))
                        return "GitHub";
                    else if (source.equals("Bioconductor"))
                        return "BioC";
                    else if (source.equals("source"))
                        return "Source";
                    else
                        return source;
                } else
                    return "";
            }
        };
        packagesTable_.addColumn(packratVersionColumn, new TextHeader("Packrat"));
        packagesTable_.addColumn(packratSourceColumn, new TextHeader("Source"));
        // distribute columns for extended package information
        packagesTable_.setColumnWidth(nameColumn, 20, Unit.PCT);
        packagesTable_.setColumnWidth(descColumn, 40, Unit.PCT);
        packagesTable_.setColumnWidth(versionColumn, 15, Unit.PCT);
        packagesTable_.setColumnWidth(packratVersionColumn, 15, Unit.PCT);
        packagesTable_.setColumnWidth(packratSourceColumn, 10, Unit.PCT);
        // highlight rows that are out of sync in packrat
        packagesTable_.setRowStyles(new PackageRowStyles());
    } else {
        // distribute columns for non-extended package information
        packagesTable_.setColumnWidth(nameColumn, 25, Unit.PCT);
        packagesTable_.setColumnWidth(descColumn, 60, Unit.PCT);
        packagesTable_.setColumnWidth(versionColumn, 15, Unit.PCT);
    }
    // remove column is common
    packagesTable_.addColumn(removeColumn, new TextHeader(""));
    packagesTable_.setColumnWidth(removeColumn, 35, Unit.PX);
    packagesTable_.setTableBuilder(new PackageTableBuilder(packagesTable_));
    packagesTable_.setSkipRowHoverCheck(true);
    packagesTableContainer_.add(packagesTable_);
    layoutPackagesTable();
    packagesDataProvider_.addDataDisplay(packagesTable_);
}
Also used : PackageInfo(org.rstudio.studio.client.workbench.views.packages.model.PackageInfo) TextHeader(com.google.gwt.user.cellview.client.TextHeader) ImageButtonColumn(org.rstudio.core.client.cellview.ImageButtonColumn) ImageButtonColumn(org.rstudio.core.client.cellview.ImageButtonColumn) 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) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)51 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)28 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)18 Header (com.google.gwt.user.cellview.client.Header)15 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)10 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)9 TextCell (com.google.gwt.cell.client.TextCell)8 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)8 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 TextColumn (com.google.gwt.user.cellview.client.TextColumn)6 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)6 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 Group (cz.metacentrum.perun.webgui.model.Group)6 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)6 ImageResource (com.google.gwt.resources.client.ImageResource)5 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)5