Search in sources :

Example 1 with Version

use of org.eclipse.equinox.p2.metadata.Version in project cubrid-manager by CUBRID.

the class UpdateHandler method doExecute.

protected void doExecute(LoadMetadataRepositoryJob job) {
    if (isNoRepos) {
        return;
    }
    UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
    // check for updates
    IStatus status = operation.resolveModal(null);
    // AUTO check update and there is not update
    if (isAutoCheckUpdate) {
        // user cancelled
        if (status.getSeverity() == IStatus.CANCEL) {
            return;
        }
        // Special case those statuses where we would never want to open a wizard
        if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
            return;
        }
        // there is no plan, so we can't continue.  Report any reason found
        if (operation.getProvisioningPlan() == null && !status.isOK()) {
            return;
        }
    }
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        if (UpdateSingleIUWizard.validFor(operation)) {
            // Special case for only updating a single root
            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            dialog.create();
            dialog.open();
        } else {
            // Open the normal version of the update wizard
            getProvisioningUI().openUpdateWizard(false, operation, job);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with Version

use of org.eclipse.equinox.p2.metadata.Version in project yamcs-studio by yamcs.

the class UpdateHandler method doExecute.

@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
    if (hasNoRepos) {
        MessageDialog.openInformation(null, "Update Yamcs Studio", "Could not check for updates since no repository is configured");
        return;
    }
    UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
    // check for updates
    operation.resolveModal(null);
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        if (UpdateSingleIUWizard.validFor(operation)) {
            // Special case for only updating a single root
            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            dialog.create();
            dialog.open();
        } else {
            // Open the normal version of the update wizard
            getProvisioningUI().openUpdateWizard(false, operation, job);
        }
    }
}
Also used : UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 3 with Version

use of org.eclipse.equinox.p2.metadata.Version in project epp.mpc by eclipse.

the class ProfileChangeOperationComputer method pruneOlderVersions.

/**
 * Remove ius from the given list where the current profile already contains a newer version of that iu.
 *
 * @param installableUnits
 * @throws CoreException
 */
private void pruneOlderVersions(List<IInstallableUnit> installableUnits) throws CoreException {
    if (!installableUnits.isEmpty()) {
        Map<String, IInstallableUnit> iUsById = MarketplaceClientUi.computeInstalledIUsById(new NullProgressMonitor());
        Iterator<IInstallableUnit> it = installableUnits.iterator();
        while (it.hasNext()) {
            IInstallableUnit iu = it.next();
            IInstallableUnit installedIu = iUsById.get(iu.getId());
            if (installedIu != null) {
                Version installedVersion = installedIu.getVersion();
                Version installableVersion = iu.getVersion();
                if (installedVersion.compareTo(installableVersion) >= 0) {
                    it.remove();
                }
            }
        }
        if (installableUnits.isEmpty()) {
            throw new CoreException(new Status(IStatus.INFO, MarketplaceClientUi.BUNDLE_ID, Messages.ProvisioningOperation_nothingToUpdate));
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) Version(org.eclipse.equinox.p2.metadata.Version) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 4 with Version

use of org.eclipse.equinox.p2.metadata.Version in project webtools.servertools by eclipse.

the class ExtensionUtility method addExtension.

private static void addExtension(List<IServerExtension> list, List<Extension> existing, IServerExtension newFeature, ExtensionListener listener) {
    if (alreadyExists(existing, newFeature))
        return;
    synchronized (list) {
        Version newV = newFeature.getVersion();
        IServerExtension remove = null;
        Iterator<IServerExtension> iterator = list.iterator();
        while (iterator.hasNext()) {
            IServerExtension feature = iterator.next();
            if (feature.getId().equals(newFeature.getId())) {
                if (newV == null)
                    // don't add if already exists
                    return;
                if (feature.getVersion().compareTo(newV) < 0) {
                    remove = feature;
                } else
                    // new feature is older
                    return;
            }
        }
        if (remove != null) {
            list.remove(remove);
            if (listener != null)
                listener.extensionRemoved((Extension) remove);
        }
        list.add(newFeature);
    }
    if (listener != null) {
        listener.extensionFound((Extension) newFeature);
    }
    if (listener == null && newFeature instanceof ExtensionProxy)
        serverExtension.add(createServerProxy((ExtensionProxy) newFeature));
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version)

Example 5 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class P2ResolverAdditionalRequirementsTest method testNullVersionInTargetDefinitionUnit.

@Test
public void testNullVersionInTargetDefinitionUnit() throws Exception {
    String nullVersion = null;
    String arbitraryVersion = "2.5.8";
    impl.addDependency(IU_TYPE, TARGET_UNIT_ID, nullVersion);
    impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, nullVersion);
    List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
    IInstallableUnit iu = createIU(arbitraryVersion);
    Assert.assertTrue("Given version was null; should be satisfied by any version", additionalRequirements.get(0).isMatch(iu));
    Assert.assertTrue("Given version was null; should be satisfied by any version", additionalRequirements.get(1).isMatch(iu));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)25 Version (org.eclipse.equinox.p2.metadata.Version)15 Test (org.junit.Test)15 File (java.io.File)12 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)12 ArrayList (java.util.ArrayList)8 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)7 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)7 IStatus (org.eclipse.core.runtime.IStatus)5 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)5 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)5 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CoreException (org.eclipse.core.runtime.CoreException)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2