Search in sources :

Example 1 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem 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;
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) Entry(java.util.Map.Entry) Operation(org.eclipse.epp.mpc.ui.Operation) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 2 with CatalogItem

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

the class MarketplaceWizard method updateSelection.

protected void updateSelection() {
    List<Entry<CatalogItem, Operation>> itemToSelectedOperation = new ArrayList<Entry<CatalogItem, Operation>>(getSelectionModel().getItemToSelectedOperation().entrySet());
    final List<CatalogItem> noninstallableItems = new ArrayList<CatalogItem>();
    for (Entry<CatalogItem, Operation> entry : itemToSelectedOperation) {
        if (entry.getValue() != Operation.NONE) {
            boolean unavailableInstall = (Boolean.FALSE.equals(entry.getKey().getAvailable()) || entry.getKey().getSiteUrl() == null) && (entry.getValue() == Operation.INSTALL || entry.getValue() == Operation.UPDATE);
            if (unavailableInstall) {
                getSelectionModel().select(entry.getKey(), Operation.NONE);
                noninstallableItems.add(entry.getKey());
            } else {
                entry.getKey().setSelected(true);
            }
        }
    }
    MarketplacePage marketplacePage = getCatalogPage();
    MarketplaceViewer viewer = marketplacePage == null ? null : marketplacePage.getViewer();
    if (marketplacePage != null && viewer != null && !viewer.getControl().isDisposed()) {
        viewer.setSelection(new StructuredSelection(viewer.getCheckedItems()));
        marketplacePage.setPageComplete(viewer.isComplete());
    }
    if (!noninstallableItems.isEmpty()) {
        notifyNonInstallableItems(noninstallableItems);
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) CatalogItemEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractProvisioningOperation(org.eclipse.epp.internal.mpc.ui.operations.AbstractProvisioningOperation) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) Operation(org.eclipse.epp.mpc.ui.Operation)

Example 3 with CatalogItem

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

the class MarketplaceWizard method computeNewInstallCatalogItems.

private Set<CatalogItem> computeNewInstallCatalogItems() {
    Set<CatalogItem> items = new HashSet<CatalogItem>();
    Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
    for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
        List<FeatureEntry> features = entry.getChildren();
        Collection<String> featureIds = new ArrayList<String>(features.size());
        for (FeatureEntry feature : features) {
            if (feature.computeChangeOperation() == Operation.INSTALL) {
                featureIds.add(feature.getFeatureDescriptor().getId());
            }
        }
        if (!featureIds.isEmpty()) {
            iusByCatalogItem.put(entry.getItem(), featureIds);
        }
    }
    for (IInstallableUnit unit : operationIUs) {
        for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
            if (entry.getValue().contains(unit.getId())) {
                items.add(entry.getKey());
            }
        }
    }
    return items;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) CatalogItemEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry) Collection(java.util.Collection) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 4 with CatalogItem

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

the class MarketplaceDiscoveryStrategy method createIcon.

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

Example 5 with CatalogItem

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

the class MarketplaceDiscoveryStrategy method addCatalogItem.

public void addCatalogItem(MarketplaceCategory catalogCategory) {
    CatalogItem catalogItem = createCategoryItem(catalogCategory);
    items.add(catalogItem);
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)

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