Search in sources :

Example 1 with ProductProperties

use of org.eclipse.ui.internal.ProductProperties 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

IOException (java.io.IOException)1 URI (java.net.URI)1 CoreException (org.eclipse.core.runtime.CoreException)1 RepositoryTracker (org.eclipse.equinox.p2.operations.RepositoryTracker)1 ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)1 ProductProperties (org.eclipse.ui.internal.ProductProperties)1