當前位置: 首頁>>代碼示例>>Java>>正文


Java Sdk.getHomeDirectory方法代碼示例

本文整理匯總了Java中com.intellij.openapi.projectRoots.Sdk.getHomeDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Sdk.getHomeDirectory方法的具體用法?Java Sdk.getHomeDirectory怎麽用?Java Sdk.getHomeDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.projectRoots.Sdk的用法示例。


在下文中一共展示了Sdk.getHomeDirectory方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkTargetJPDAInstalled

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
private static void checkTargetJPDAInstalled(JavaParameters parameters) throws ExecutionException {
  final Sdk jdk = parameters.getJdk();
  if (jdk == null) {
    throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
  }
  final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  String versionString = jdk.getVersionString();
  if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) {
    throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString));
  }
  if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) {
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
      throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString));
    }
    //noinspection HardCodedStringLiteral
    File dllFile = new File(
      homeDirectory.getPath().replace('/', File.separatorChar) + File.separator + "bin" + File.separator + "jdwp.dll"
    );
    if (!dllFile.exists()) {
      GetJPDADialog dialog = new GetJPDADialog();
      dialog.show();
      throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing"));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:DebuggerManagerImpl.java

示例2: getInitialSdkLocation

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
/**
 * Returns initial SDK location. That will be the SDK location from the installer
 * handoff file in the handoff case, sdk location location from the preference if set
 * or platform-dependant default path.
 */
@NotNull
public static File getInitialSdkLocation(@NotNull FirstRunWizardMode mode) {
  File dest = mode.getSdkLocation();
  if (dest != null) {
    return dest;
  }
  else {
    List<Sdk> sdks = AndroidSdkUtils.getAllAndroidSdks();
    Sdk sdk = Iterables.getFirst(sdks, null);
    if (sdk != null) {
      VirtualFile homeDirectory = sdk.getHomeDirectory();
      if (homeDirectory != null) {
        return VfsUtilCore.virtualToIoFile(homeDirectory);
      }
    }
    return getDefaultSdkLocation();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FirstRunWizardDefaults.java

示例3: getValidJdkToRunModule

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
public static Sdk getValidJdkToRunModule(final Module module, boolean productionOnly) throws CantRunException {
  Sdk jdk = getJdkToRunModule(module, productionOnly);
  if (jdk == null) {
    throw CantRunException.noJdkForModule(module);
  }
  final VirtualFile homeDirectory = jdk.getHomeDirectory();
  if (homeDirectory == null || !homeDirectory.isValid()) {
    throw CantRunException.jdkMisconfigured(jdk, module);
  }
  return jdk;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:JavaParameters.java

示例4: PropertyFileGeneratorImpl

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
/**
 * A constctor that extracts all neeed properties for ant build from the project.
 *
 * @param project    a project to examine
 * @param genOptions generation options
 */
public PropertyFileGeneratorImpl(Project project, GenerationOptions genOptions) {
  // path variables
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNamesSet = pathMacros.getUserMacroNames();
  if (macroNamesSet.size() > 0) {
    final String[] macroNames = ArrayUtil.toStringArray(macroNamesSet);
    Arrays.sort(macroNames);
    for (final String macroName : macroNames) {
      addProperty(BuildProperties.getPathMacroProperty(macroName), pathMacros.getValue(macroName));
    }
  }
  // jdk homes
  if (genOptions.forceTargetJdk) {
    final Sdk[] usedJdks = BuildProperties.getUsedJdks(project);
    for (Sdk jdk : usedJdks) {
      if (jdk.getHomeDirectory() == null) {
        continue;
      }
      final File homeDir = BuildProperties.toCanonicalFile(VfsUtil.virtualToIoFile(jdk.getHomeDirectory()));
      addProperty(BuildProperties.getJdkHomeProperty(jdk.getName()), homeDir.getPath().replace(File.separatorChar, '/'));
    }
  }
  // generate idea.home property
  if (genOptions.isIdeaHomeGenerated()) {
    addProperty(BuildProperties.PROPERTY_IDEA_HOME, PathManager.getHomePath());
  }

  if (genOptions.enableFormCompiler) {
    addProperty(BuildProperties.PROPERTY_INCLUDE_JAVA_RUNTIME_FOR_INSTRUMENTATION, genOptions.forceTargetJdk? "false" : "true");
  }

  ChunkBuildExtension.generateAllProperties(this, project, genOptions);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:PropertyFileGeneratorImpl.java

示例5: expand

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
@Override
public String expand(DataContext dataContext) throws ExecutionCancelledException {
  Module module = LangDataKeys.MODULE.getData(dataContext);
  if (module == null) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
      return null;
    }
    Module[] modules = ModuleManager.getInstance(project).getModules();
    if (modules.length == 0) {
      return null;
    }
    module = modules[0];
  }
  Sdk sdk = PythonSdkType.findPythonSdk(module);
  if (sdk != null) {
    VirtualFile homeDir = sdk.getHomeDirectory();
    if (homeDir == null) {
      return null;
    }
    String path = PathUtil.getLocalPath(homeDir.getParent());
    if (path != null) {
      return FileUtil.toSystemDependentName(path);
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:29,代碼來源:InterpreterDirectoryMacro.java

示例6: isCondaVEnv

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public static boolean isCondaVEnv(Sdk sdk) {
  final String condaName = "conda-meta";
  final VirtualFile homeDirectory = sdk.getHomeDirectory();
  if (homeDirectory == null) return false;
  final VirtualFile condaExecutable = SystemInfo.isWindows ? homeDirectory.getParent().findChild(condaName) :
                                      homeDirectory.getParent().getParent().findChild(condaName);
  return condaExecutable != null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:PyCondaPackageManagerImpl.java

示例7: getSdkPath

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public static String getSdkPath(@Nullable Sdk sdk) {
  if (sdk == null) return null;

  VirtualFile homeDirectory = sdk.getHomeDirectory();
  if (homeDirectory == null) return null;

  if (!"jre".equals(homeDirectory.getName())) {
    VirtualFile jreDir = homeDirectory.findChild("jre");
    if (jreDir != null) {
      homeDirectory = jreDir;
    }
  }

  return homeDirectory.getPath();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:MavenUtil.java


注:本文中的com.intellij.openapi.projectRoots.Sdk.getHomeDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。