use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.
the class MarketplacePage method hasFavoritedTab.
private boolean hasFavoritedTab(ICatalogBranding branding) {
if (branding.hasFavoritesTab()) {
return true;
}
CatalogDescriptor catalogDescriptor = this.configuration.getCatalogDescriptor();
if (catalogDescriptor == null) {
return false;
}
URL url = catalogDescriptor.getUrl();
IUserFavoritesService favoritesService = url == null ? null : ServiceHelper.getMarketplaceServiceLocator().getFavoritesService(url.toString());
return favoritesService != null;
}
use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method removeLoginListener.
public synchronized void removeLoginListener(LoginListener loginListener) {
if (loginListeners != null) {
loginListeners.remove(loginListener);
}
IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
if (favoritesService != null) {
IMarketplaceStorageService storageService = favoritesService.getStorageService();
storageService.removeLoginListener(loginListener);
}
}
use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.
the class ImportFavoritesPage method performImport.
public void performImport() {
setErrorMessage(null);
saveInstallSelected();
List<MarketplaceNodeCatalogItem> importFavorites = getSelection();
if (importFavorites.isEmpty()) {
return;
}
final IUserFavoritesService userFavoritesService = findUserFavoritesService();
if (userFavoritesService == null) {
return;
}
final List<INode> importNodes = new ArrayList<INode>();
for (MarketplaceNodeCatalogItem item : importFavorites) {
importNodes.add(item.getData());
}
try {
getContainer().run(true, false, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
userFavoritesService.getStorageService().runWithLogin(new Callable<Void>() {
public Void call() throws Exception {
try {
userFavoritesService.addFavorites(importNodes, monitor);
} catch (NotAuthorizedException e) {
setErrorMessage(Messages.ImportFavoritesPage_unauthorizedErrorMessage);
} catch (ConflictException e) {
setErrorMessage(Messages.ImportFavoritesPage_conflictErrorMessage);
}
return null;
}
});
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
MarketplaceClientCore.error(cause);
setErrorMessage(NLS.bind(Messages.ImportFavoritesPage_unknownErrorMessage, cause));
} catch (InterruptedException e) {
// ignore
}
}
use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.
the class DefaultMarketplaceService method userFavorites.
public void userFavorites(List<? extends INode> nodes, IProgressMonitor monitor) throws NotAuthorizedException, CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.DefaultMarketplaceService_FavoritesUpdate, 10000);
IUserFavoritesService userFavoritesService = getUserFavoritesService();
if (userFavoritesService == null) {
throw new UnsupportedOperationException();
}
if (nodes == null || nodes.isEmpty()) {
return;
}
Set<String> favorites = null;
try {
favorites = userFavoritesService == null ? null : userFavoritesService.getFavoriteIds(progress);
} catch (NotAuthorizedException e) {
throw e;
} catch (Exception e) {
throw new CoreException(MarketplaceClientCore.computeStatus(e, Messages.DefaultMarketplaceService_FavoritesErrorRetrieving));
} finally {
for (INode node : nodes) {
((Node) node).setUserFavorite(favorites == null ? null : favorites.contains(node.getId()));
}
}
}
use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.
the class DefaultMarketplaceService method userFavorites.
public ISearchResult userFavorites(URI favoritesUri, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.DefaultMarketplaceService_FavoritesRetrieve, 10000);
IUserFavoritesService userFavoritesService = getUserFavoritesService();
if (userFavoritesService == null) {
throw new UnsupportedOperationException();
}
final List<INode> favorites;
try {
favorites = userFavoritesService.getFavorites(favoritesUri, progress.newChild(1000));
} catch (Exception e) {
throw new CoreException(MarketplaceClientCore.computeStatus(e, Messages.DefaultMarketplaceService_FavoritesErrorRetrieving));
}
progress.setWorkRemaining(9000);
return resolveFavoriteNodes(favorites, progress.newChild(9000), false);
}
Aggregations