Search in sources :

Example 1 with ResolveFeatureNamesOperation

use of org.eclipse.epp.internal.mpc.ui.operations.ResolveFeatureNamesOperation 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();
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) ResolveFeatureNamesOperation(org.eclipse.epp.internal.mpc.ui.operations.ResolveFeatureNamesOperation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Display(org.eclipse.swt.widgets.Display)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 ResolveFeatureNamesOperation (org.eclipse.epp.internal.mpc.ui.operations.ResolveFeatureNamesOperation)1 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 Display (org.eclipse.swt.widgets.Display)1