/** Note: Used by Grails tooling */
  public static boolean isGroovyVersionDisabledOrMissing(SpecifiedVersion version) {
    BundleDescription disabledBundle = null;
    disabledBundle = getDisabledBundleDescription(version);
    if (disabledBundle != null) {
      return true;
    }

    Bundle[] active = Platform.getBundles("org.codehaus.groovy", version.toVersionString());
    if (active == null) {
      return true;
    }

    // getBundles returns bundles with version >= specified version,
    // so must do one more check to see if there is a bundle where the
    // major.minor version matches
    for (Bundle bundle : active) {
      Version bundleVersion = bundle.getVersion();
      if (bundleVersion.getMajor() == version.majorVersion
          && bundleVersion.getMajor() == version.majorVersion) {
        return false;
      }
    }
    // no bundle with specifed version has been found
    return true;
  }
 static SpecifiedVersion getWorkspaceCompilerLevel() {
   String groovyVersion = GroovySystem.getVersion();
   // convert from major.minor.micro to major.minor
   int dotIndex = groovyVersion.lastIndexOf('.');
   if (dotIndex > 0) {
     groovyVersion = groovyVersion.substring(0, dotIndex);
   }
   return SpecifiedVersion.findVersionFromString(groovyVersion);
 }
 public static SpecifiedVersion getCompilerLevel(IProject project) {
   SpecifiedVersion version = UNSPECIFIED;
   if (GroovyNature.hasGroovyNature(project)) {
     String groovyCompilerLevelStr = Activator.getDefault().getGroovyCompilerLevel(project);
     if (groovyCompilerLevelStr != null) {
       version = SpecifiedVersion.findVersionFromString(groovyCompilerLevelStr);
     }
   }
   return version;
 }
  /**
   * Main entry point to generate UI for compiler switching
   *
   * @param compilerPage
   */
  public static Composite createCompilerSwitchBlock(Composite parent) {
    Composite compilerPage = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 3;
    layout.marginWidth = 3;
    compilerPage.setLayout(layout);

    SpecifiedVersion activeGroovyVersion = CompilerUtils.getActiveGroovyVersion();
    Label compilerVersion = new Label(compilerPage, SWT.LEFT | SWT.WRAP);
    compilerVersion.setText(
        "You are currently using Groovy Compiler version "
            + CompilerUtils.getGroovyVersion()
            + ".");

    for (SpecifiedVersion version : SpecifiedVersion.values()) {
      if (activeGroovyVersion != version) {
        switchVersion(version, compilerPage);
      }
    }

    Link moreInfoLink = new Link(compilerPage, 0);
    moreInfoLink.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    moreInfoLink.setText(
        "<a href=\"http://docs.codehaus.org/display/GROOVY/Compiler+Switching+within+Groovy-Eclipse\">See here</a> for more information "
            + "on compiler switching (opens a browser window).");
    moreInfoLink.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            openUrl(event.text);
          }
        });

    return compilerPage;
  }
 public static SpecifiedVersion getActiveGroovyVersion() {
   BundleDescription groovyBundle = getActiveGroovyBundleDescription();
   return SpecifiedVersion.findVersion(groovyBundle.getVersion());
 }