Search in sources :

Example 1 with Operation

use of org.eclipse.epp.mpc.ui.Operation 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 Operation

use of org.eclipse.epp.mpc.ui.Operation 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 Operation

use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.

the class MarketplaceWizard method importFavorites.

protected void importFavorites(MarketplaceDiscoveryStrategy marketplaceStrategy, String url) {
    FavoritesCatalog favoritesCatalog = new FavoritesCatalog();
    ImportFavoritesWizard importFavoritesWizard = new ImportFavoritesWizard(favoritesCatalog, getConfiguration(), this);
    importFavoritesWizard.setInitialFavoritesUrl(url);
    final ImportFavoritesPage importFavoritesPage = importFavoritesWizard.getImportFavoritesPage();
    favoritesCatalog.getDiscoveryStrategies().add(new FavoritesDiscoveryStrategy(marketplaceStrategy) {

        private String discoveryError = null;

        @Override
        protected void preDiscovery() {
            discoveryError = null;
        }

        @Override
        protected void handleDiscoveryError(CoreException ex) throws CoreException {
            discoveryError = ImportFavoritesPage.handleDiscoveryError(getFavoritesReference(), ex);
        }

        @Override
        protected void postDiscovery() {
            final String errorMessage = this.discoveryError;
            this.discoveryError = null;
            importFavoritesPage.setDiscoveryError(errorMessage);
        }
    });
    ImportFavoritesWizardDialog importWizard = new ImportFavoritesWizardDialog(getShell(), importFavoritesWizard);
    Map<String, Operation> oldOperations = getSelectionModel().getItemIdToSelectedOperation();
    int result = importWizard.open();
    if (result == Window.OK) {
        MarketplacePage catalogPage = getCatalogPage();
        catalogPage.setActiveTab(ContentType.FAVORITES);
        catalogPage.reloadCatalog();
        Map<String, Operation> newOperations = getSelectionModel().getItemIdToSelectedOperation();
        if (!newOperations.equals(oldOperations)) {
            updateSelection();
        }
    }
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) CoreException(org.eclipse.core.runtime.CoreException) 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) FavoritesCatalog(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesCatalog)

Example 4 with Operation

use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.

the class ImportFavoritesWizard method openFavoritesInMarketplace.

private void openFavoritesInMarketplace(List<MarketplaceNodeCatalogItem> selection) {
    final IMarketplaceClientService clientService = MarketplaceClient.getMarketplaceClientService();
    final IMarketplaceClientConfiguration config = clientService.newConfiguration();
    MarketplaceCatalogConfiguration catalogConfiguration = getConfiguration();
    config.setCatalogDescriptors(catalogConfiguration.getCatalogDescriptors());
    config.setCatalogDescriptor(catalogConfiguration.getCatalogDescriptor());
    Map<String, Operation> initialOperations = new HashMap<String, Operation>();
    for (MarketplaceNodeCatalogItem item : selection) {
        initialOperations.put(item.getData().getId(), Operation.INSTALL);
    }
    config.setInitialOperations(initialOperations);
    Display.getCurrent().asyncExec(new Runnable() {

        public void run() {
            clientService.openFavorites(config);
        }
    });
}
Also used : IMarketplaceClientConfiguration(org.eclipse.epp.mpc.ui.IMarketplaceClientConfiguration) HashMap(java.util.HashMap) IMarketplaceClientService(org.eclipse.epp.mpc.ui.IMarketplaceClientService) Operation(org.eclipse.epp.mpc.ui.Operation) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 5 with Operation

use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.

the class ItemButtonController method updateButtonState.

private void updateButtonState() {
    primaryState = ButtonState.DISABLED;
    selectableStates = Collections.emptyList();
    MarketplaceNodeCatalogItem catalogItem = (MarketplaceNodeCatalogItem) item.getData();
    if (catalogItem.getInstallableUnits().isEmpty()) {
        return;
    }
    List<Operation> availableOperations = catalogItem.getAvailableOperations();
    if (availableOperations.isEmpty()) {
        return;
    }
    Operation selectedOperation = item.getSelectedOperation();
    Operation primaryOperation = selectedOperation;
    switch(selectedOperation) {
        case UPDATE:
            primaryState = ButtonState.UPDATE_PENDING;
            break;
        case UNINSTALL:
            primaryState = ButtonState.UNINSTALL_PENDING;
            break;
        case CHANGE:
            primaryState = ButtonState.CHANGE_PENDING;
            break;
        case INSTALL:
            primaryState = ButtonState.INSTALL_PENDING;
            break;
        case NONE:
            primaryOperation = availableOperations.get(0);
            primaryState = ButtonState.forOperation(primaryOperation);
            break;
    }
    if (availableOperations.size() > 1) {
        selectableStates = new ArrayList<ButtonState>(availableOperations.size() - 1);
        for (Operation operation : availableOperations) {
            if (operation != primaryOperation) {
                ButtonState selectableState = ButtonState.forOperation(operation);
                if (selectableState != ButtonState.DISABLED) {
                    selectableStates.add(selectableState);
                }
            }
        }
    }
}
Also used : Operation(org.eclipse.epp.mpc.ui.Operation) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Aggregations

Operation (org.eclipse.epp.mpc.ui.Operation)18 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)9 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)8 HashMap (java.util.HashMap)6 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)6 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)6 UninstallOperation (org.eclipse.equinox.p2.operations.UninstallOperation)6 IStatus (org.eclipse.core.runtime.IStatus)5 CoreException (org.eclipse.core.runtime.CoreException)4 Status (org.eclipse.core.runtime.Status)4 AbstractProvisioningOperation (org.eclipse.epp.internal.mpc.ui.operations.AbstractProvisioningOperation)4 FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Entry (java.util.Map.Entry)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 InstallOperation (org.eclipse.equinox.p2.operations.InstallOperation)2