Search in sources :

Example 1 with TextHeader

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

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

the class ModifyKeyboardShortcutsWidget method editableTextColumn.

private Column<KeyboardShortcutEntry, String> editableTextColumn(String name, final ValueGetter<KeyboardShortcutEntry> getter) {
    EditTextCell editTextCell = new EditTextCell() {

        @Override
        public void onBrowserEvent(final Context context, final Element parent, final String value, final NativeEvent event, final ValueUpdater<String> updater) {
            // handler.
            if (event.getType().equals("keyup") && event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
                parent.getFirstChildElement().blur();
                return;
            }
            super.onBrowserEvent(context, parent, value, event, updater);
        }
    };
    Column<KeyboardShortcutEntry, String> column = new Column<KeyboardShortcutEntry, String>(editTextCell) {

        @Override
        public String getValue(KeyboardShortcutEntry binding) {
            return getter.getValue(binding);
        }
    };
    column.setFieldUpdater(new FieldUpdater<KeyboardShortcutEntry, String>() {

        @Override
        public void update(int index, KeyboardShortcutEntry binding, String value) {
            KeySequence keys = KeySequence.fromShortcutString(value);
            // adding a new key sequence.
            if (keys.equals(binding.getOriginalKeySequence())) {
                changes_.remove(binding);
                binding.restoreOriginalKeySequence();
            } else {
                KeyboardShortcutEntry newBinding = new KeyboardShortcutEntry(binding.getId(), binding.getName(), keys, binding.getCommandType(), true, binding.getContext());
                changes_.put(binding, newBinding);
                binding.setKeySequence(keys);
            }
            table_.setKeyboardSelectedColumn(0);
            updateData(dataProvider_.getList());
        }
    });
    column.setSortable(true);
    table_.addColumn(column, new TextHeader(name));
    return column;
}
Also used : EditTextCell(com.google.gwt.cell.client.EditTextCell) Element(com.google.gwt.dom.client.Element) TableRowElement(com.google.gwt.dom.client.TableRowElement) TextHeader(com.google.gwt.user.cellview.client.TextHeader) JsArrayString(com.google.gwt.core.client.JsArrayString) ValueUpdater(com.google.gwt.cell.client.ValueUpdater) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) KeySequence(org.rstudio.core.client.command.KeyboardShortcut.KeySequence) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 3 with TextHeader

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

the class ModifyKeyboardShortcutsWidget method textColumn.

private TextColumn<KeyboardShortcutEntry> textColumn(String name, final ValueGetter<KeyboardShortcutEntry> getter) {
    TextColumn<KeyboardShortcutEntry> column = new TextColumn<KeyboardShortcutEntry>() {

        @Override
        public String getValue(KeyboardShortcutEntry binding) {
            return getter.getValue(binding);
        }
    };
    column.setSortable(true);
    table_.addColumn(column, new TextHeader(name));
    return column;
}
Also used : TextHeader(com.google.gwt.user.cellview.client.TextHeader) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 4 with TextHeader

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

the class BrowseAddinsDialog method addColumns.

private void addColumns() {
    // Package ----
    pkgColumn_ = new TextColumn<RAddin>() {

        @Override
        public String getValue(RAddin addin) {
            return addin.getPackage();
        }
    };
    pkgColumn_.setSortable(true);
    table_.addColumn(pkgColumn_, new TextHeader("Package"));
    table_.setColumnWidth(pkgColumn_, "120px");
    // Name ----
    nameColumn_ = new TextColumn<RAddin>() {

        @Override
        public String getValue(RAddin addin) {
            return StringUtil.truncate(addin.getName(), 120, "...");
        }
    };
    nameColumn_.setSortable(true);
    table_.addColumn(nameColumn_, new TextHeader("Name"));
    table_.setColumnWidth(nameColumn_, "120px");
    // Description ----
    descColumn_ = new TextColumn<RAddin>() {

        @Override
        public String getValue(RAddin addin) {
            return addin.getDescription();
        }
    };
    descColumn_.setSortable(true);
    table_.addColumn(descColumn_, new TextHeader("Description"));
    table_.addColumnSortHandler(new ColumnSortEvent.Handler() {

        @Override
        public void onColumnSort(ColumnSortEvent event) {
            int index = -1;
            if (event.getColumn().equals(pkgColumn_))
                index = 0;
            else if (event.getColumn().equals(nameColumn_))
                index = 1;
            else if (event.getColumn().equals(descColumn_))
                index = 2;
            if (index == -1)
                return;
            sort(index, event.isSortAscending());
        }
    });
}
Also used : RAddin(org.rstudio.studio.client.workbench.addins.Addins.RAddin) TextHeader(com.google.gwt.user.cellview.client.TextHeader) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent)

Aggregations

TextHeader (com.google.gwt.user.cellview.client.TextHeader)4 TextColumn (com.google.gwt.user.cellview.client.TextColumn)3 Column (com.google.gwt.user.cellview.client.Column)2 EditTextCell (com.google.gwt.cell.client.EditTextCell)1 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Element (com.google.gwt.dom.client.Element)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 TableRowElement (com.google.gwt.dom.client.TableRowElement)1 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)1 ImageButtonColumn (org.rstudio.core.client.cellview.ImageButtonColumn)1 LinkColumn (org.rstudio.core.client.cellview.LinkColumn)1 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 RAddin (org.rstudio.studio.client.workbench.addins.Addins.RAddin)1 PackageInfo (org.rstudio.studio.client.workbench.views.packages.model.PackageInfo)1