use of org.rstudio.studio.client.workbench.views.packages.model.PackageInfo in project rstudio by rstudio.
the class PackagesPane method packageRow.
private int packageRow(String packageName, String packageLib) {
// if we haven't retreived packages yet then return not found
if (packagesDataProvider_ == null)
return -1;
List<PackageInfo> packages = packagesDataProvider_.getList();
// figure out which row of the table includes this package
int row = -1;
for (int i = 0; i < packages.size(); i++) {
PackageInfo packageInfo = packages.get(i);
if (packageInfo.getName().equals(packageName) && packageInfo.getLibrary().equals(packageLib)) {
row = i;
break;
}
}
return row;
}
use of org.rstudio.studio.client.workbench.views.packages.model.PackageInfo 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 org.rstudio.studio.client.workbench.views.packages.model.PackageInfo in project rstudio by rstudio.
the class Packages method setPackageState.
private void setPackageState(PackageState newState) {
// sort the packages
allPackages_ = new ArrayList<PackageInfo>();
JsArray<PackageInfo> serverPackages = newState.getPackageList();
for (int i = 0; i < serverPackages.length(); i++) allPackages_.add(serverPackages.get(i));
Collections.sort(allPackages_, new Comparator<PackageInfo>() {
public int compare(PackageInfo o1, PackageInfo o2) {
// sort first by library, then by name
int library = PackageLibraryUtils.typeOfLibrary(session_, o1.getLibrary()).compareTo(PackageLibraryUtils.typeOfLibrary(session_, o2.getLibrary()));
return library == 0 ? o1.getName().compareToIgnoreCase(o2.getName()) : library;
}
});
// mark packages out of sync if they have pending actions, and mark
// which packages are first in their respective libraries
// (used later to render headers)
Set<String> outOfSyncPackages = new TreeSet<String>();
getPackageNamesFromActions(newState.getRestoreActions(), outOfSyncPackages);
getPackageNamesFromActions(newState.getSnapshotActions(), outOfSyncPackages);
PackageLibraryType libraryType = PackageLibraryType.None;
for (PackageInfo pkgInfo : allPackages_) {
if (pkgInfo.getInPackratLibary() && outOfSyncPackages.contains(pkgInfo.getName())) {
pkgInfo.setOutOfSync(true);
}
PackageLibraryType pkgLibraryType = PackageLibraryUtils.typeOfLibrary(session_, pkgInfo.getLibrary());
if (pkgLibraryType != libraryType) {
pkgInfo.setFirstInLibrary(true);
libraryType = pkgLibraryType;
}
}
packratContext_ = newState.getPackratContext();
view_.setProgress(false);
setViewPackageList();
setViewActions(newState);
}
use of org.rstudio.studio.client.workbench.views.packages.model.PackageInfo in project rstudio by rstudio.
the class Packages method setViewPackageList.
private void setViewPackageList() {
ArrayList<PackageInfo> packages = null;
// apply filter (if any)
if (packageFilter_.length() > 0) {
packages = new ArrayList<PackageInfo>();
// first do prefix search
for (PackageInfo pkgInfo : allPackages_) {
if (pkgInfo.getName().toLowerCase().startsWith(packageFilter_))
packages.add(pkgInfo);
}
// then do contains search on name & desc
for (PackageInfo pkgInfo : allPackages_) {
if (pkgInfo.getName().toLowerCase().contains(packageFilter_) || pkgInfo.getDesc().toLowerCase().contains(packageFilter_)) {
if (!packages.contains(pkgInfo))
packages.add(pkgInfo);
}
}
// sort results by library (to preserve grouping)
Collections.sort(packages, new Comparator<PackageInfo>() {
@Override
public int compare(PackageInfo o1, PackageInfo o2) {
return PackageLibraryUtils.typeOfLibrary(session_, o1.getLibrary()).compareTo(PackageLibraryUtils.typeOfLibrary(session_, o2.getLibrary()));
}
});
} else {
packages = allPackages_;
}
view_.setPackageState(packratContext_, packages);
}
use of org.rstudio.studio.client.workbench.views.packages.model.PackageInfo in project rstudio by rstudio.
the class PackagesPane method createMainWidget.
@Override
protected Widget createMainWidget() {
packagesDataProvider_ = new ListDataProvider<PackageInfo>();
packagesTableContainer_ = new LayoutPanel();
return packagesTableContainer_;
}
Aggregations