Search in sources :

Example 1 with InstallOperation

use of org.eclipse.equinox.p2.operations.InstallOperation in project knime-core by knime.

the class InstallMissingNodesJob method startInstallJob.

private void startInstallJob(final Set<IInstallableUnit> featuresToInstall) {
    final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
    Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
    final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(provUI);
    loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
    loadJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(final IJobChangeEvent event) {
            if (PlatformUI.isWorkbenchRunning() && event.getResult().isOK()) {
                Display.getDefault().asyncExec(() -> {
                    if (Display.getDefault().isDisposed()) {
                        NodeLogger.getLogger("Display disposed, aborting install action");
                        // fixes AP-8376, AP-8380, AP-7184
                        return;
                    }
                    provUI.getPolicy().setRepositoriesVisible(false);
                    provUI.openInstallWizard(featuresToInstall, new InstallOperation(provUI.getSession(), featuresToInstall), loadJob);
                    provUI.getPolicy().setRepositoriesVisible(true);
                });
            }
        }
    });
    loadJob.setUser(true);
    loadJob.schedule();
}
Also used : ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) LoadMetadataRepositoryJob(org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob)

Example 2 with InstallOperation

use of org.eclipse.equinox.p2.operations.InstallOperation in project archi by archimatetool.

the class P2Handler method install.

public IStatus install(URI uri, IProgressMonitor monitor) throws ProvisionException {
    loadRepository(uri, monitor);
    Collection<IInstallableUnit> toInstall = getGroupInstallableUnits(uri, monitor);
    InstallOperation operation = new InstallOperation(getProvisioningSession(), toInstall);
    return performOperation(operation, monitor);
}
Also used : InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 3 with InstallOperation

use of org.eclipse.equinox.p2.operations.InstallOperation in project gemoc-studio by eclipse.

the class PrepareInstallProfileJob method run.

public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
    try {
        SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.InstallConnectorsJob_task_configuring, 100);
        try {
            final Collection<IInstallableUnit> ius = computeInstallableUnits(monitor.newChild(50));
            checkCancelled(monitor);
            final InstallOperation installOperation = resolve(monitor.newChild(50), ius, repositoryLocations.toArray(new URI[0]));
            checkCancelled(monitor);
            if (!headless) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        openInstallWizard(provisioningUI, ius, installOperation);
                    }
                });
            }
        } finally {
            monitor.done();
        }
    } catch (OperationCanceledException e) {
        throw new InterruptedException();
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) MalformedURLException(java.net.MalformedURLException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with InstallOperation

use of org.eclipse.equinox.p2.operations.InstallOperation in project gemoc-studio by eclipse.

the class PrepareInstallProfileJob method resolve.

private InstallOperation resolve(IProgressMonitor monitor, final Collection<IInstallableUnit> ius, URI[] repositories) throws CoreException {
    final InstallOperation installOperation = provisioningUI.getInstallOperation(ius, repositories);
    IStatus operationStatus = installOperation.resolveModal(new SubProgressMonitor(monitor, installableConnectors.size()));
    if (operationStatus.getSeverity() > IStatus.WARNING) {
        Activator.getDefault().getLog().log(operationStatus);
        throw new RuntimeException(getFullMessage(operationStatus));
    }
    return installOperation;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 5 with InstallOperation

use of org.eclipse.equinox.p2.operations.InstallOperation in project azure-tools-for-java by Microsoft.

the class PluginUtil method forceInstallPluginUsingP2.

private static void forceInstallPluginUsingP2(String pluginGroupID) {
    URI repoURI = getEclipseP2Repository();
    ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
    if (provisioningUI != null && repoURI != null) {
        ProvisioningSession provisioningSession = provisioningUI.getSession();
        IProvisioningAgent provisioningAgent = null;
        if (provisioningSession != null && (provisioningAgent = provisioningSession.getProvisioningAgent()) != null) {
            IMetadataRepositoryManager manager = (IMetadataRepositoryManager) provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
            if (manager != null) {
                try {
                    IMetadataRepository repository = manager.loadRepository(repoURI, null);
                    if (repository != null) {
                        IQueryResult<IInstallableUnit> iqr = repository.query(QueryUtil.createIUQuery(pluginGroupID), null);
                        if (iqr != null) {
                            Collection<IInstallableUnit> iuList = StreamSupport.stream(iqr.spliterator(), false).collect(Collectors.toList());
                            if (iuList.size() > 0) {
                                InstallOperation io = new InstallOperation(provisioningSession, iuList);
                                provisioningUI.openInstallWizard(iuList, io, null);
                                return;
                            }
                        }
                    }
                } catch (Exception e) {
                    String errorMsg = "Error installing " + pluginGroupID + "! Please manually install using Eclipse P2 repository from: Help -> Install New Software.... Click OK to continue.";
                    PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, e);
                }
            }
        }
    }
    String errorMsg = "Error installing " + pluginGroupID + "! In the following installation wizard, please select the right repository and then filter by " + pluginGroupID + "! Click OK to continue.";
    PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, null);
    provisioningUI.openInstallWizard(null, null, null);
}
Also used : ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IMetadataRepositoryManager(org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager) ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) URI(java.net.URI) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

InstallOperation (org.eclipse.equinox.p2.operations.InstallOperation)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 URI (java.net.URI)2 CoreException (org.eclipse.core.runtime.CoreException)2 ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 IStatus (org.eclipse.core.runtime.IStatus)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)1 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)1 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)1