Search in sources :

Example 11 with ProvisioningUI

use of org.eclipse.equinox.p2.ui.ProvisioningUI in project liferay-ide by liferay.

the class LiferayUIPlugin method _addRepository.

private void _addRepository() throws URISyntaxException {
    ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
    ProvisioningSession provisioningSession = provisioningUI.getSession();
    RepositoryTracker repositoryTracker = provisioningUI.getRepositoryTracker();
    URI[] knownRepositories = repositoryTracker.getKnownRepositories(provisioningSession);
    URI liferayUri = new URI("https://releases.liferay.com/tools/ide/latest/stable/");
    boolean containLifreayUri = Stream.of(knownRepositories).anyMatch(uri -> Objects.equals(uri, liferayUri));
    if (!containLifreayUri) {
        repositoryTracker.addRepository(liferayUri, "Liferay IDE Stable releases", provisioningSession);
    }
}
Also used : ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) URI(java.net.URI) RepositoryTracker(org.eclipse.equinox.p2.operations.RepositoryTracker)

Example 12 with ProvisioningUI

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

the class PluginUtil method getEclipseP2Repository.

private static URI getEclipseP2Repository() {
    String repoPrefix = "download.eclipse.org/releases/";
    ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
    if (provisioningUI != null) {
        RepositoryTracker tracker = provisioningUI.getRepositoryTracker();
        if (tracker != null) {
            URI[] sites = tracker.getKnownRepositories(provisioningUI.getSession());
            for (URI site : sites) {
                if (site.toString().contains(repoPrefix)) {
                    return site;
                }
            }
        }
    }
    String start = "Version: ";
    String end = " (";
    URI repoSite = null;
    ProductProperties productProperties = new ProductProperties(Platform.getProduct());
    if (productProperties != null) {
        String aboutText = productProperties.getAboutText();
        int startIndex = aboutText.indexOf(start);
        int endIndex = aboutText.indexOf(end);
        String eclipseSimutaneousReleaseVersion = "";
        if (startIndex >= 0 && endIndex >= 0 && endIndex > startIndex) {
            eclipseSimutaneousReleaseVersion = aboutText.substring(startIndex + start.length(), endIndex);
            try {
                repoSite = new URI("http://" + repoPrefix + eclipseSimutaneousReleaseVersion.toLowerCase());
            } catch (Exception e) {
                repoSite = null;
            }
        }
    }
    return repoSite;
}
Also used : ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) ProductProperties(org.eclipse.ui.internal.ProductProperties) URI(java.net.URI) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) RepositoryTracker(org.eclipse.equinox.p2.operations.RepositoryTracker)

Aggregations

ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)10 URI (java.net.URI)5 RepositoryTracker (org.eclipse.equinox.p2.operations.RepositoryTracker)4 IOException (java.io.IOException)3 CoreException (org.eclipse.core.runtime.CoreException)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 InstallOperation (org.eclipse.equinox.p2.operations.InstallOperation)3 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)3 UpdateOperation (org.eclipse.equinox.p2.operations.UpdateOperation)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 URISyntaxException (java.net.URISyntaxException)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)2 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)2 LoadMetadataRepositoryJob (org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1