com.intellij.openapi.projectRoots.SdkAdditionalData Java Examples

The following examples show how to use com.intellij.openapi.projectRoots.SdkAdditionalData. 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: HaxelibCommandUtils.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
/**
 * Find the path to the 'haxelib' executable, using a specific SDK.
 *
 * @param sdk - SDK to look up haxelib for.
 * @return the configured haxelib for the SDK; "haxelib" if not specified.
 */
@NotNull
public static String getHaxelibPath(@NotNull Sdk sdk) {

  String haxelibPath = "haxelib";
  if (sdk != null) {
    SdkAdditionalData data = sdk.getSdkAdditionalData();

    if (data instanceof HaxeSdkData) {
      HaxeSdkData sdkData = (HaxeSdkData)data;
      String path = sdkData.getHaxelibPath();
      if (!path.isEmpty()) {
        haxelibPath = path;
      }
    }
  }

  return haxelibPath;
}
 
Example #2
Source File: OCamlSdkType.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public SdkAdditionalData loadAdditionalData(@NotNull Element additional) {
    OCamlSdkAdditionalData data = new OCamlSdkAdditionalData();
    data.setMajor(additional.getAttributeValue("major"));
    data.setMinor(additional.getAttributeValue("minor"));
    data.setPatch(additional.getAttributeValue("patch"));
    data.setForced(Boolean.getBoolean(additional.getAttributeValue("forced")));
    return data;
}
 
Example #3
Source File: OCamlSdkType.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void saveAdditionalData(@NotNull SdkAdditionalData data, @NotNull Element additional) {
    OCamlSdkAdditionalData odkAdditionalData = (OCamlSdkAdditionalData) data;
    additional.setAttribute("major", odkAdditionalData.getMajor());
    additional.setAttribute("minor", odkAdditionalData.getMinor());
    additional.setAttribute("patch", odkAdditionalData.getPatch());
    additional.setAttribute("forced", odkAdditionalData.isForced().toString());
}
 
Example #4
Source File: OCamlAdditionalDataConfigurable.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void setSdk(Sdk sdk) {
    m_sdk = sdk;
    SdkAdditionalData data = sdk.getSdkAdditionalData();
    if (data == null) {
        String versionString = sdk.getVersionString();
        if (versionString != null) {
            OCamlSdkAdditionalData oData = new OCamlSdkAdditionalData();
            oData.setVersionFromHome(versionString);
            ((ProjectJdkImpl) sdk).setSdkAdditionalData(oData);
        }
    }
}
 
Example #5
Source File: BaseSdkCompat.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** #api193: SdkConfigurationUtil changed in 2020.1. */
public static ProjectJdkImpl createSdk(
    Collection<? extends Sdk> allSdks,
    VirtualFile homeDir,
    SdkType sdkType,
    @Nullable SdkAdditionalData additionalData,
    @Nullable String customSdkSuggestedName) {
  return SdkConfigurationUtil.createSdk(
      allSdks.toArray(new Sdk[0]), homeDir, sdkType, additionalData, customSdkSuggestedName);
}
 
Example #6
Source File: BaseSdkCompat.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** #api193: SdkConfigurationUtil changed in 2020.1. */
public static ProjectJdkImpl createSdk(
    Collection<? extends Sdk> allSdks,
    VirtualFile homeDir,
    SdkType sdkType,
    @Nullable SdkAdditionalData additionalData,
    @Nullable String customSdkSuggestedName) {
  return SdkConfigurationUtil.createSdk(
      allSdks, homeDir, sdkType, additionalData, customSdkSuggestedName);
}
 
Example #7
Source File: HaxeSdkUtilBase.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
public static HaxeSdkAdditionalDataBase getSdkData(@Nullable Sdk sdk) {
  if(sdk != null) {
    SdkAdditionalData sdkData = sdk.getSdkAdditionalData();
    if(sdkData != null && sdkData instanceof HaxeSdkAdditionalDataBase) {
      return (HaxeSdkAdditionalDataBase)sdkData;
    }
  }
  return null;
}
 
Example #8
Source File: MockSdkWrapper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public SdkAdditionalData getSdkAdditionalData() {
  return null;
}
 
Example #9
Source File: SdkConfigurationUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static Sdk setupSdk(final Sdk[] allSdks,
                           final VirtualFile homeDir,
                           final SdkType sdkType,
                           final boolean silent,
                           boolean predefined,
                           @Nullable final SdkAdditionalData additionalData,
                           @Nullable final String customSdkSuggestedName) {
  final SdkImpl sdk;
  try {
    String sdkPath = sdkType.sdkPath(homeDir);

    String sdkName = null;
    if (predefined) {
      sdkName = sdkType.getName() + PREDEFINED_PREFIX;
    }
    else {
      sdkName = customSdkSuggestedName == null
                ? createUniqueSdkName(sdkType, sdkPath, allSdks)
                : createUniqueSdkName(customSdkSuggestedName, allSdks);
    }

    sdk = new SdkImpl(SdkTable.getInstance(), sdkName, sdkType);
    sdk.setPredefined(predefined);

    if (additionalData != null) {
      // additional initialization.
      // E.g. some ruby sdks must be initialized before
      // setupSdkPaths() method invocation
      sdk.setSdkAdditionalData(additionalData);
    }

    sdk.setHomePath(sdkPath);
    sdkType.setupSdkPaths((Sdk)sdk);
  }
  catch (Exception e) {
    if (!silent) {
      Messages.showErrorDialog("Error configuring SDK: " +
                               e.getMessage() +
                               ".\nPlease make sure that " +
                               FileUtil.toSystemDependentName(homeDir.getPath()) +
                               " is a valid home path for this SDK type.", "Error Configuring SDK");
    }
    return null;
  }
  return sdk;
}