use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method createCategoryItem.
private CatalogItem createCategoryItem(MarketplaceCategory catalogCategory) {
CatalogItem catalogItem = new CatalogItem();
catalogItem.setSource(source);
catalogItem.setData(catalogDescriptor);
catalogItem.setId(catalogDescriptor.getUrl().toString());
catalogItem.setCategoryId(catalogCategory.getId());
return catalogItem;
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method refreshUserFavorites.
public void refreshUserFavorites(IProgressMonitor monitor) throws CoreException {
final SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_FavoritesRefreshing, 1001);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
List<CatalogItem> items = catalogCategory.getItems();
if (hasUserFavoritesService()) {
Map<String, INode> nodes = new HashMap<String, INode>();
for (CatalogItem item : items) {
Object data = item.getData();
if (data instanceof INode) {
INode node = (INode) data;
nodes.put(node.getId(), node);
}
}
if (nodes.isEmpty()) {
return;
}
try {
applyShellProvider();
marketplaceService.userFavorites(new ArrayList<INode>(nodes.values()), progress.newChild(500));
for (CatalogItem catalogItem : items) {
if (catalogItem instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) catalogItem;
INode node = nodes.get(nodeItem.getId());
nodeItem.setUserFavorite(node == null ? null : node.getUserFavorite());
}
}
} catch (NotAuthorizedException e) {
catalogCategory = addPopularItems(progress.newChild(500));
addUserStorageLoginItem(catalogCategory, e.getLocalizedMessage());
} catch (UnsupportedOperationException ex) {
catalogCategory = addPopularItems(progress.newChild(500));
addFavoritesNotSupportedItem(catalogCategory);
} catch (Exception ex) {
// FIXME we should use the wizard page's status line to show errors, but that's unreachable from here...
MarketplaceClientCore.error(Messages.MarketplaceDiscoveryStrategy_FavoritesRetrieveError, ex);
addRetryErrorItem(catalogCategory, ex);
}
} else {
for (CatalogItem catalogItem : items) {
if (catalogItem instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) catalogItem;
nodeItem.setUserFavorite(null);
}
}
}
} finally {
monitor.done();
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method updateFeatures.
private void updateFeatures() {
SelectionModel selectionModel = getWizard().getSelectionModel();
Set<CatalogItem> allSelectionCatalogItems = selectionModel.getItemToSelectedOperation().keySet();
Set<CatalogItem> selectedCatalogItems = selectionModel.getSelectedCatalogItems();
if (allSelectionCatalogItems.isEmpty() || selectedCatalogItems.isEmpty()) {
showPreviousPage();
return;
}
viewer.setInput(selectionModel);
ResolveFeatureNamesOperation operation = new ResolveFeatureNamesOperation(new ArrayList<CatalogItem>(allSelectionCatalogItems)) {
Display display = getControl().getDisplay();
@Override
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
super.run(progressMonitor);
if (!display.isDisposed() && isActivePage()) {
display.asyncExec(new Runnable() {
public void run() {
if (isActivePage()) {
updateFeatureDescriptors(getFeatureDescriptors(), getUnresolvedFeatureDescriptors());
}
}
});
}
}
};
try {
getContainer().run(true, true, operation);
} catch (InvocationTargetException e) {
// we only log here since any error will also be displayed when resolving the provisioning operation.
int statusFlags = StatusManager.LOG;
IStatus status;
if (e.getCause() instanceof ProvisionException) {
status = ((ProvisionException) e.getCause()).getStatus();
} else {
status = MarketplaceClientCore.computeStatus(e, Messages.FeatureSelectionWizardPage_unexpectedException_verifyingFeatures);
statusFlags |= StatusManager.BLOCK | StatusManager.SHOW;
}
MarketplaceClientUi.handle(status, statusFlags);
} catch (InterruptedException e) {
// canceled
} finally {
if (!isActivePage()) {
return;
}
refresh();
// bug 470485: need to recompute button state, because run() resets that to previous state
refreshState();
}
// maybeUpdateProfileChangeOperation();
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class FavoritesViewer method catalogUpdated.
@Override
protected void catalogUpdated(boolean wasCancelled, boolean wasError) {
List<CatalogItem> items = getCatalog().getItems();
Set<CatalogItem> selectedItems = new LinkedHashSet<CatalogItem>();
for (CatalogItem catalogItem : items) {
if (catalogItem.isSelected()) {
selectedItems.add(catalogItem);
}
}
setSelection(StructuredSelection.EMPTY);
super.catalogUpdated(wasCancelled, wasError);
setSelection(new StructuredSelection(new ArrayList<CatalogItem>(selectedItems)));
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class InstallAllActionLink method installAll.
protected void installAll() {
MarketplaceViewer viewer = marketplacePage.getViewer();
List<CatalogItem> items = viewer.getCatalog().getItems();
// We need to first select the items in the selection model and then
// set the selection to the viewer. Otherwise the MarketplacePage listener
// will advance the wizard on the first selected item.
SelectionModel selectionModel = viewer.getSelectionModel();
for (CatalogItem catalogItem : items) {
if (catalogItem instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) catalogItem;
if (selectionModel.getSelectedOperation(nodeItem) == Operation.NONE) {
selectionModel.select(nodeItem, Operation.INSTALL);
}
}
}
// viewer.getCheckedItems() is based on the SelectionModel state, so it already has the
// updated selection. Just let the viewer synchronize its remaining selection state with it.
viewer.setSelection(new StructuredSelection(viewer.getCheckedItems()));
if (!viewer.getSelection().isEmpty()) {
marketplacePage.showNextPage();
}
}
Aggregations