Search in sources :

Example 1 with ImageButtonColumn

use of org.rstudio.core.client.cellview.ImageButtonColumn 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)

Example 2 with ImageButtonColumn

use of org.rstudio.core.client.cellview.ImageButtonColumn in project rstudio by rstudio.

the class CheckForUpdatesDialog method addTableColumns.

protected void addTableColumns(CellTable<PendingAction> table) {
    TextColumn<PendingAction> nameColumn = new TextColumn<PendingAction>() {

        public String getValue(PendingAction action) {
            return action.getActionInfo().getPackageName();
        }
    };
    table.addColumn(nameColumn, "Package");
    table.setColumnWidth(nameColumn, 28, Unit.PCT);
    TextColumn<PendingAction> installedColumn = new TextColumn<PendingAction>() {

        public String getValue(PendingAction action) {
            return action.getActionInfo().getInstalled();
        }
    };
    table.addColumn(installedColumn, "Installed");
    table.setColumnWidth(installedColumn, 28, Unit.PCT);
    TextColumn<PendingAction> availableColumn = new TextColumn<PendingAction>() {

        public String getValue(PendingAction action) {
            return action.getActionInfo().getAvailable();
        }
    };
    table.addColumn(availableColumn, "Available");
    table.setColumnWidth(availableColumn, 28, Unit.PCT);
    ImageButtonColumn<PendingAction> newsColumn = new ImageButtonColumn<PendingAction>(new ImageResource2x(ThemeResources.INSTANCE.newsButton2x()), new OperationWithInput<PendingAction>() {

        public void execute(PendingAction action) {
            GlobalDisplay.NewWindowOptions options = new GlobalDisplay.NewWindowOptions();
            options.setName("_rstudio_package_news");
            globalDisplay_.openWindow(action.getActionInfo().getNewsUrl(), options);
        }
    }, "Show package NEWS") {

        @Override
        protected boolean showButton(PendingAction action) {
            return !StringUtil.isNullOrEmpty(action.getActionInfo().getNewsUrl());
        }
    };
    table.addColumn(newsColumn, "NEWS");
    table.setColumnWidth(newsColumn, 16, Unit.PCT);
}
Also used : GlobalDisplay(org.rstudio.studio.client.common.GlobalDisplay) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) TextColumn(com.google.gwt.user.cellview.client.TextColumn) ImageButtonColumn(org.rstudio.core.client.cellview.ImageButtonColumn)

Aggregations

TextColumn (com.google.gwt.user.cellview.client.TextColumn)2 ImageButtonColumn (org.rstudio.core.client.cellview.ImageButtonColumn)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 Column (com.google.gwt.user.cellview.client.Column)1 TextHeader (com.google.gwt.user.cellview.client.TextHeader)1 LinkColumn (org.rstudio.core.client.cellview.LinkColumn)1 GlobalDisplay (org.rstudio.studio.client.common.GlobalDisplay)1 PackageInfo (org.rstudio.studio.client.workbench.views.packages.model.PackageInfo)1