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_);
}
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;
}
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;
}
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());
}
});
}
Aggregations