use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method setupCatalog.
protected void setupCatalog() throws MalformedURLException {
final SearchResult discoveryResult = new SearchResult();
discoveryResult.setNodes(discoveryNodes);
CatalogDescriptor catalogDescriptor = new CatalogDescriptor();
catalogDescriptor.setUrl(new URL("http://marketplace.eclipse.org"));
MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
final MarketplaceCategory category = new MarketplaceCategory();
{
category.setId("<root>");
}
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (!categories.contains(category)) {
categories.add(category);
}
handleSearchResult(category, discoveryResult, new NullProgressMonitor());
}
@Override
protected synchronized Map<String, IInstallableUnit> computeInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
for (INode node : installedNodes) {
IIus ius = node.getIus();
if (ius != null) {
for (IIu iu : ius.getIuElements()) {
String featureId = iu.getId() + ".feature.group";
InstallableUnit installableUnit = new InstallableUnit();
installableUnit.setId(featureId);
installedIus.put(featureId, installableUnit);
}
}
}
return installedIus;
}
@Override
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
return category;
}
};
catalog = new MarketplaceCatalog() {
@Override
protected IStatus checkForUpdates(List<MarketplaceNodeCatalogItem> updateCheckNeeded, final Map<String, IInstallableUnit> installedIUs, final IProgressMonitor monitor) {
for (MarketplaceNodeCatalogItem item : updateCheckNeeded) {
checkedForUpdate.add(item.getData());
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
boolean hasUpdate = updateAvailable.contains(item.getData());
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
iuItem.setUpdateAvailable(hasUpdate);
}
}
return Status.OK_STATUS;
}
};
catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class MarketplacePage method canSkipFeatureSelection.
protected boolean canSkipFeatureSelection() {
SelectionModel selectionModel = getWizard().getSelectionModel();
Map<CatalogItem, Operation> selectedOperations = selectionModel.getItemToSelectedOperation();
Set<Entry<CatalogItem, Operation>> entrySet = selectedOperations.entrySet();
Operation mode = null;
for (Entry<CatalogItem, Operation> entry : entrySet) {
if (!(entry.getKey() instanceof MarketplaceNodeCatalogItem)) {
return false;
}
MarketplaceNodeCatalogItem item = (MarketplaceNodeCatalogItem) entry.getKey();
Operation value = entry.getValue();
switch(value) {
case NONE:
continue;
case INSTALL:
case UPDATE:
if (mode == null) {
mode = Operation.INSTALL;
} else if (mode == Operation.UNINSTALL) {
return false;
}
if (hasOptionalFeatures(item)) {
return false;
}
break;
case UNINSTALL:
if (mode == null) {
mode = Operation.UNINSTALL;
} else if (mode == Operation.INSTALL) {
return false;
}
if (hasOptionalFeatures(item)) {
return false;
}
break;
case CHANGE:
return false;
}
}
if (mode == null) {
return false;
}
return true;
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem 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.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class DiscoveryItem method isFavorited.
private boolean isFavorited() {
MarketplaceNodeCatalogItem nodeConnector = (MarketplaceNodeCatalogItem) connector;
Boolean favorited = nodeConnector.getUserFavorite();
return Boolean.TRUE.equals(favorited);
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class ImportFavoritesWizard method selectForInstallation.
private void selectForInstallation(List<MarketplaceNodeCatalogItem> selection) {
MarketplacePage catalogPage = parent.getCatalogPage();
if (catalogPage.getActiveTab() != ContentType.FAVORITES) {
catalogPage.setActiveTab(ContentType.FAVORITES);
}
for (MarketplaceNodeCatalogItem item : selection) {
parent.getSelectionModel().select(item, Operation.INSTALL);
}
parent.getContainer().showPage(catalogPage);
}
Aggregations