Search in sources :

Example 11 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class FavoritesDiscoveryStrategy method addInfoItem.

private void addInfoItem(CatalogCategory catalogCategory, String title, String description) {
    MarketplaceCatalogSource source = getCatalogSource();
    // $NON-NLS-1$
    String id = catalogDescriptor.getUrl().toString() + "#info:" + title;
    for (ListIterator<CatalogItem> i = items.listIterator(items.size()); i.hasPrevious(); ) {
        CatalogItem item = i.previous();
        if (item.getSource() == source && (item.getCategory() == catalogCategory || catalogCategory.getId().equals(item.getCategoryId())) && item instanceof UserActionCatalogItem) {
            UserActionCatalogItem actionItem = (UserActionCatalogItem) item;
            if (actionItem.getUserAction() == UserAction.INFO && id.equals(actionItem.getId())) {
                return;
            }
        }
    }
    UserActionCatalogItem infoItem = new UserActionCatalogItem();
    infoItem.setUserAction(UserAction.INFO);
    infoItem.setDescription(description);
    infoItem.setName(title);
    infoItem.setId(id);
    addItem(catalogCategory, infoItem);
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)

Example 12 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class FavoritesDiscoveryStrategy method createIcon.

private static void createIcon(CatalogItem catalogItem, final IFavoriteList list) {
    Icon icon = new Icon();
    // don't know the size
    icon.setImage32(list.getIcon());
    icon.setImage48(list.getIcon());
    icon.setImage64(list.getIcon());
    icon.setImage128(list.getIcon());
    catalogItem.setIcon(icon);
}
Also used : Icon(org.eclipse.equinox.internal.p2.discovery.model.Icon)

Example 13 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class MarketplaceCatalog method checkForUpdates.

public IStatus checkForUpdates(final IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceCatalog_checkingForUpdates, 10000000);
    try {
        Map<String, IInstallableUnit> installedIUs = calculateInstalledIUs(progress.newChild(100000));
        List<MarketplaceNodeCatalogItem> updateCheckNeeded = new ArrayList<MarketplaceNodeCatalogItem>();
        for (CatalogItem item : getItems()) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            if (!(item instanceof MarketplaceNodeCatalogItem)) {
                continue;
            }
            MarketplaceNodeCatalogItem catalogItem = (MarketplaceNodeCatalogItem) item;
            if (catalogItem.isInstalled()) {
                if (setUpdatesAvailable(installedIUs, catalogItem)) {
                    updateCheckNeeded.add(catalogItem);
                }
            }
        }
        if (!updateCheckNeeded.isEmpty()) {
            checkForUpdates(updateCheckNeeded, installedIUs, progress.newChild(10000000 - 100000));
        }
        return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
    } finally {
        monitor.done();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) SubMonitor(org.eclipse.core.runtime.SubMonitor) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 14 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class MarketplaceCatalog method removeItem.

public void removeItem(CatalogItem item) {
    getItems().remove(item);
    getFilteredItems().remove(item);
    for (CatalogCategory category : getCategories()) {
        category.getItems().remove(item);
    }
}
Also used : CatalogCategory(org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)

Example 15 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class SelectionModel method computeProvisioningOperationViability.

/**
 * Determine what message related to finishing the wizard should correspond to the current selection.
 *
 * @return the message, or null if there should be no message.
 */
public IStatus computeProvisioningOperationViability() {
    IStatus featureStatus = computeFeatureOperationViability();
    if (featureStatus == null || !featureStatus.isOK()) {
        return featureStatus;
    }
    Map<Operation, List<CatalogItem>> operationToItem = computeOperationToItem();
    if (operationToItem.size() == 0) {
        return new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, Messages.SelectionModel_Nothing_Selected);
    } else if (operationToItem.size() == 1) {
        Entry<Operation, List<CatalogItem>> entry = operationToItem.entrySet().iterator().next();
        return new Status(IStatus.INFO, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.SelectionModel_count_selectedFor_operation, entry.getValue().size() == 1 ? Messages.SelectionModel_oneSolution : NLS.bind(Messages.SelectionModel_countSolutions, entry.getValue().size()), entry.getKey().getLabel()));
    } else if (operationToItem.size() == 2 && operationToItem.containsKey(Operation.INSTALL) && operationToItem.containsKey(Operation.UPDATE)) {
        int count = 0;
        for (List<CatalogItem> items : operationToItem.values()) {
            count += items.size();
        }
        return new Status(IStatus.INFO, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.SelectionModel_countSolutionsSelectedForInstallUpdate, count));
    } else {
        return new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, Messages.SelectionModel_cannotInstallRemoveConcurrently);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) IStatus(org.eclipse.core.runtime.IStatus) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) Operation(org.eclipse.epp.mpc.ui.Operation)

Aggregations

CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)30 ArrayList (java.util.ArrayList)10 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)9 Operation (org.eclipse.epp.mpc.ui.Operation)9 HashSet (java.util.HashSet)7 INode (org.eclipse.epp.mpc.core.model.INode)7 CoreException (org.eclipse.core.runtime.CoreException)6 IStatus (org.eclipse.core.runtime.IStatus)6 HashMap (java.util.HashMap)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Status (org.eclipse.core.runtime.Status)4 FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)4 URISyntaxException (java.net.URISyntaxException)3 Entry (java.util.Map.Entry)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 CatalogCategory (org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)3 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)3