com.intellij.util.text.VersionComparatorUtil Java Examples

The following examples show how to use com.intellij.util.text.VersionComparatorUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KPXStartupNotification.java    From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
  public void runActivity(@NotNull Project project) {
    if (ApplicationManager.getApplication().isUnitTestMode()) return;

    final Application application = ApplicationManager.getApplication();
    final KeyPromoterSettings settings = ServiceManager.getService(KeyPromoterSettings.class);
    final String installedVersion = settings.getInstalledVersion();

    final IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(PluginId.getId("Key Promoter X"));
    if (installedVersion != null && plugin != null) {
      final int compare = VersionComparatorUtil.compare(installedVersion, plugin.getVersion());
//      if (true) { // TODO: Don't forget to remove that! For proofreading.
      if (compare < 0) {
        application.invokeLater(() -> KPXStartupDialog.showStartupDialog(project));
        settings.setInstalledVersion(plugin.getVersion());
      }
    }
  }
 
Example #2
Source File: CheckUpdatesAction.java    From r2m-plugin-android with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {

        Properties updatesInfo = new Properties();
        InputStream infoStream = null;

        String url = R2MConstants.PUBLIC_VERSION_URL;
        try {
            infoStream = URLHelper.loadUrl(url);
            updatesInfo.load(infoStream);
        } catch (Exception ex) {
            UIHelper.showErrorMessage("Couldn't access version URL: " + R2MConstants.PUBLIC_VERSION_URL);
            Logger.error(CheckUpdatesAction.class, ex.getMessage());
            return;
        } finally {
            if (infoStream != null) {
                try {
                    infoStream.close();
                } catch (IOException e1) {
                    // ignore
                }
            }
        }

        String latestVersion = updatesInfo.getProperty(R2MConstants.LATEST_VERSION_KEY);
        String installedVersion = getInstalledVersion();

        Project project = e.getData(CommonDataKeys.PROJECT);
        if (VersionComparatorUtil.compare(installedVersion, latestVersion) >= 0) {
            showNoUpdateDialog(project, installedVersion, updatesInfo);
            return;
        }

        showUpdatesAvailableDialog(project, installedVersion, updatesInfo);

    }
 
Example #3
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private Sdk findLatestVersion(@NotNull Sdk mainSdk, @NotNull Set<Sdk> sdks) {
    Sdk result = mainSdk;
    for (Sdk sdk : sdks) {
        if (VersionComparatorUtil.compare(result.getVersionString(), sdk.getVersionString()) < 0) {
            result = sdk;
        }
    }
    return result;
}
 
Example #4
Source File: TYPO3Utility.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
/**
 * Examples: 1.0rc1 < 1.0release, 1.0 < 1.0.1, 1.1 > 1.02
 *
 * @return 0 if cms version equals given version, positive value if cms version > given version, negative value if cms version < given version
 */
public static Integer compareVersion(@NotNull Project project, String version) {
    String typo3Version = getTYPO3Version(project);

    return VersionComparatorUtil.compare(typo3Version, version);
}
 
Example #5
Source File: TYPO3Utility.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
/**
 * Examples: 1.0rc1 < 1.0release, 1.0 < 1.0.1, 1.1 > 1.02
 *
 * @return 0 if cms version equals given version, positive value if cms version > given version, negative value if cms version < given version
 */
public static Integer compareMajorMinorVersion(@NotNull Project project, String version) {
    String typo3Version = getTYPO3Branch(project);

    return VersionComparatorUtil.compare(typo3Version, version);
}
 
Example #6
Source File: SymfonyUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static boolean isVersionGreaterThenEquals(@NotNull Project project, @NotNull String version) {
    return compare(project, version, contents -> VersionComparatorUtil.compare(contents, version) >= 0);
}
 
Example #7
Source File: SymfonyUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static boolean isVersionGreaterThen(@NotNull Project project, @NotNull String version) {
    return compare(project, version, contents -> VersionComparatorUtil.compare(contents, version) > 0);
}
 
Example #8
Source File: SymfonyUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static boolean isVersionLessThenEquals(@NotNull Project project, @NotNull String version) {
    return compare(project, version, contents -> VersionComparatorUtil.compare(contents, version) <= 0);
}
 
Example #9
Source File: SymfonyUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static boolean isVersionLessThen(@NotNull Project project, @NotNull String version) {
    return compare(project, version, contents -> VersionComparatorUtil.compare(contents, version) < 0);
}