Search in sources :

Example 1 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project translationstudio8 by heartsome.

the class UpdateDescriptionPage method getUpdateDescDetailText.

private String getUpdateDescDetailText() {
    StringBuffer descBf = new StringBuffer();
    Update[] updates = operation.getSelectedUpdates();
    if (updates.length == 0) {
        // no udpates;
        setPageComplete(false);
        return P2UpdateUtil.UPDATE_PROMPT_INFO_NO_UPDATE;
    }
    Update update = updates[0];
    AvailableUpdateElement newElement = new AvailableUpdateElement(null, update.replacement, update.toUpdate, ui.getProfileId(), ProvUI.getQueryContext(ui.getPolicy()).getShowProvisioningPlanChildren());
    descBf.append(P2UpdateUtil.UI_WIZARD_DESC_PAGE_DESC_DETAIL).append(newElement.getIU().getVersion()).append("\n\n");
    newElement.setQueryable(operation.getProvisioningPlan().getAdditions());
    Object[] children = newElement.getChildren(newElement);
    StringBuffer temp = new StringBuffer();
    if (children != null && children.length != 0) {
        AvailableIUElement c = (AvailableIUElement) children[0];
        String detail = c.getIU().getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
        if (detail == null)
            detail = "";
        temp.append(detail);
    }
    String descResult = "";
    if (temp.length() != 0) {
        String lang = CommonFunction.getSystemLanguage();
        String szh = "[-zh-]";
        String sen = "[-en-]";
        if (lang.equals("en")) {
            descResult = temp.substring(sen.length() + 1, temp.indexOf(szh) - 1);
        } else if (lang.equals("zh")) {
            descResult = temp.substring(temp.indexOf(szh) + szh.length() + 1, temp.length());
        }
    }
    return descBf.append(descResult).toString();
// String detail = "";
// Object[] elements = root.getChildren(root);
// if(elements.length > 0){
// AvailableUpdateElement element = (AvailableUpdateElement) elements[0];
// Object[] children = element.getChildren(element);
// if(children != null && children.length != 0){
// AvailableIUElement c = (AvailableIUElement) children[0];
// IInstallableUnit selectedIU = ElementUtils.elementToIU(c);
// detail = selectedIU.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
// if (detail == null)
// detail = "";
// }
// }
}
Also used : AvailableUpdateElement(org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) Update(org.eclipse.equinox.p2.operations.Update) AvailableIUElement(org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement)

Example 2 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project knime-core by knime.

the class InstallMissingNodesJob method findExtensions.

private IStatus findExtensions(final IProgressMonitor monitor, final List<NodeAndBundleInformation> missingNodes, final Set<IInstallableUnit> featuresToInstall) {
    ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
    Bundle myself = FrameworkUtil.getBundle(getClass());
    try {
        IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
        for (URI uri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
            if (!missingNodes.isEmpty()) {
                IMetadataRepository repo = metadataManager.loadRepository(uri, monitor);
                for (Iterator<NodeAndBundleInformation> it = missingNodes.iterator(); it.hasNext(); ) {
                    NodeAndBundleInformation info = it.next();
                    if (searchInRepository(repo, info, metadataManager, monitor, featuresToInstall)) {
                        it.remove();
                    }
                }
            }
        }
        return Status.OK_STATUS;
    } catch (ProvisionException ex) {
        NodeLogger.getLogger(getClass()).error("Could not create provisioning agent: " + ex.getMessage(), ex);
        return new Status(IStatus.ERROR, myself.getSymbolicName(), "Could not query updates site for missing extensions", ex);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IMetadataRepositoryManager(org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager) NodeAndBundleInformation(org.knime.core.node.NodeAndBundleInformation) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) Bundle(org.osgi.framework.Bundle) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) URI(java.net.URI)

Example 3 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit 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 4 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit 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 5 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project gemoc-studio by eclipse.

the class PrepareInstallProfileJob method computeInstallableUnits.

public Collection<IInstallableUnit> computeInstallableUnits(SubMonitor monitor) throws CoreException {
    try {
        monitor.setWorkRemaining(100);
        // add repository urls and load meta data
        List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
        final List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
        removeOldVersions(installableUnits);
        checkForUnavailable(installableUnits);
        return installableUnits;
    // MultiStatus status = new MultiStatus(DiscoveryUi.ID_PLUGIN, 0,
    // Messages.PrepareInstallProfileJob_ok, null);
    // ius = installableUnits.toArray(new
    // IInstallableUnit[installableUnits.size()]);
    // ProfileChangeRequest profileChangeRequest =
    // InstallAction.computeProfileChangeRequest(ius, profileId,
    // status, new SubProgressMonitor(monitor,
    // installableConnectors.size()));
    // if (status.getSeverity() > IStatus.WARNING) {
    // throw new CoreException(status);
    // }
    // if (profileChangeRequest == null) {
    // // failed but no indication as to why
    // throw new CoreException(new Status(IStatus.ERROR,
    // DiscoveryUi.ID_PLUGIN,
    // Messages.PrepareInstallProfileJob_computeProfileChangeRequestFailed,
    // null));
    // }
    // PlannerResolutionOperation operation = new
    // PlannerResolutionOperation(
    // Messages.PrepareInstallProfileJob_calculatingRequirements,
    // profileId, profileChangeRequest, null,
    // status, true);
    // IStatus operationStatus = operation.execute(new
    // SubProgressMonitor(monitor, installableConnectors.size()));
    // if (operationStatus.getSeverity() > IStatus.WARNING) {
    // throw new CoreException(operationStatus);
    // }
    // 
    // plannerResolutionOperation = operation;
    } catch (URISyntaxException e) {
        // should never happen, since we already validated URLs.
        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.InstallConnectorsJob_unexpectedError_url, e));
    } catch (MalformedURLException e) {
        // should never happen, since we already validated URLs.
        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.InstallConnectorsJob_unexpectedError_url, e));
    } finally {
        monitor.done();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) URISyntaxException(java.net.URISyntaxException) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)149 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)43 File (java.io.File)38 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)25 HashSet (java.util.HashSet)18 IStatus (org.eclipse.core.runtime.IStatus)17 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)16 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)14 HashMap (java.util.HashMap)13 LinkedHashSet (java.util.LinkedHashSet)11 CoreException (org.eclipse.core.runtime.CoreException)11 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)11 URI (java.net.URI)10 SubMonitor (org.eclipse.core.runtime.SubMonitor)9 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)9 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 Status (org.eclipse.core.runtime.Status)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8