use of org.rstudio.studio.client.workbench.views.packages.model.PackageLibraryUtils.PackageLibraryType 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);
}
Aggregations