本文整理匯總了Java中com.intellij.openapi.projectRoots.Sdk.getHomePath方法的典型用法代碼示例。如果您正苦於以下問題:Java Sdk.getHomePath方法的具體用法?Java Sdk.getHomePath怎麽用?Java Sdk.getHomePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.projectRoots.Sdk
的用法示例。
在下文中一共展示了Sdk.getHomePath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAndroidSdkPath
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public static String getAndroidSdkPath(Project project) {
ModuleManager manager = ModuleManager.getInstance(project);
String androidSdkPath = null;
for (Module module : manager.getModules()) {
if (androidSdkPath != null) {
break;
}
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getHomePath() != null) {
File file = new File(sdk.getHomePath());
String[] contents = file.list();
if (contents != null) {
for (String path : contents) {
if (path.equals("build-tools")) {
androidSdkPath = sdk.getHomePath();
break;
}
}
}
}
}
return androidSdkPath;
}
示例2: findAppropriateAndroidPlatform
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
public static Sdk findAppropriateAndroidPlatform(@NotNull IAndroidTarget target, @NotNull AndroidSdkData sdkData, boolean forMaven) {
for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
String homePath = sdk.getHomePath();
if (homePath != null && isAndroidSdk(sdk)) {
AndroidSdkData currentSdkData = getSdkData(homePath);
if (sdkData.equals(currentSdkData)) {
AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);
if (data != null) {
IAndroidTarget currentTarget = data.getBuildTarget(currentSdkData);
if (currentTarget != null &&
target.hashString().equals(currentTarget.hashString()) &&
checkSdkRoots(sdk, target, forMaven)) {
return sdk;
}
}
}
}
}
return null;
}
示例3: update
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Override
public void update(PresentationData presentation) {
presentation.setPresentableText(getValue().getName());
final OrderEntry orderEntry = getValue().getOrderEntry();
Icon closedIcon = orderEntry instanceof JdkOrderEntry ? getJdkIcon((JdkOrderEntry)orderEntry) : AllIcons.Nodes.PpLibFolder;
presentation.setIcon(closedIcon);
if (orderEntry instanceof JdkOrderEntry) {
final JdkOrderEntry jdkOrderEntry = (JdkOrderEntry)orderEntry;
final Sdk projectJdk = jdkOrderEntry.getJdk();
if (projectJdk != null) { //jdk not specified
final String path = projectJdk.getHomePath();
if (path != null) {
presentation.setLocationString(FileUtil.toSystemDependentName(path));
}
}
presentation.setTooltip(null);
}
else {
presentation.setTooltip(StringUtil.capitalize(IdeBundle.message("node.projectview.library", ((LibraryOrderEntry)orderEntry).getLibraryLevel())));
}
}
示例4: findPathOfSdkMissingOrEmptyAddonsFolder
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
private static File findPathOfSdkMissingOrEmptyAddonsFolder(@NotNull Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
for (Module module : moduleManager.getModules()) {
Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
if (moduleSdk != null && isAndroidSdk(moduleSdk)) {
String homePath = moduleSdk.getHomePath();
if (homePath != null) {
File sdkHomeDirPath = new File(FileUtil.toSystemDependentName(homePath));
File addonsDir = new File(sdkHomeDirPath, SdkConstants.FD_ADDONS);
if (!addonsDir.isDirectory() || FileUtil.notNullize(addonsDir.listFiles()).length == 0) {
return sdkHomeDirPath;
}
}
}
}
return null;
}
示例5: createNewAndroidPlatform
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
/**
* Creates a new IDEA Android SDK. User is prompt for the paths of the Android SDK and JDK if necessary.
*
* @param sdkPath the path of Android SDK.
* @return the created IDEA Android SDK, or {@null} if it was not possible to create it.
*/
@Nullable
public static Sdk createNewAndroidPlatform(@Nullable String sdkPath, boolean promptUser) {
Sdk jdk = chooseOrCreateJavaSdk();
if (sdkPath != null && jdk != null) {
sdkPath = toSystemIndependentName(sdkPath);
IAndroidTarget target = findBestTarget(sdkPath);
if (target != null) {
Sdk sdk = createNewAndroidPlatform(target, sdkPath, chooseNameForNewLibrary(target), jdk, true);
if (sdk != null) {
return sdk;
}
}
}
String jdkPath = jdk == null ? null : jdk.getHomePath();
return promptUser ? promptUserForSdkCreation(null, sdkPath, jdkPath) : null;
}
示例6: generateBuiltinSkeletons
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public void generateBuiltinSkeletons(@NotNull Sdk sdk) throws InvalidSdkException {
//noinspection ResultOfMethodCallIgnored
new File(mySkeletonsPath).mkdirs();
String binaryPath = sdk.getHomePath();
if (binaryPath == null) throw new InvalidSdkException("Broken home path for " + sdk.getName());
long startTime = System.currentTimeMillis();
final ProcessOutput runResult = getProcessOutput(
new File(binaryPath).getParent(),
new String[]{
binaryPath,
PythonHelpersLocator.getHelperPath(GENERATOR3),
"-d", mySkeletonsPath, // output dir
"-b", // for builtins
},
PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5
);
runResult.checkSuccess(LOG);
LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
}
示例7: getAndroidSdkPath
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
private String getAndroidSdkPath() {
Sdk[] allSdks = ProjectJdkTable.getInstance().getAllJdks();
for (Sdk sdk : allSdks) {
String sdkTypeName = sdk.getSdkType().getName();
if (ANDROID_SDK_TYPE_NAME.equals(sdkTypeName)) {
return sdk.getHomePath();
}
}
return null;
}
示例8: createCheckProcess
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
}
final File testRunner = new File(myTaskDir.getPath(), testsFileName);
myCommandLine = new GeneralCommandLine();
myCommandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = myCommandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
myCommandLine.setExePath(pythonPath);
myCommandLine.addParameter(testRunner.getPath());
myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return myCommandLine.createProcess();
}
}
return null;
}
示例9: getSdkSelected
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
private Sdk getSdkSelected() {
String sdkHome = getSdkHome();
if (StringUtil.isEmptyOrSpaces(sdkHome)) {
final Sdk projectJdk = PythonSdkType.findPythonSdk(getModule());
if (projectJdk != null) {
sdkHome = projectJdk.getHomePath();
}
}
return PythonSdkType.findSdkByPath(sdkHome);
}
示例10: createCheckProcess
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
Course course = myTask.getLesson().getCourse();
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
LOG.info("Language manager is null for " + course.getLanguageById().getDisplayName());
return null;
}
final File testRunner = new File(myTaskDir.getPath(), manager.getTestFileName());
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = commandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
commandLine.setExePath(pythonPath);
commandLine.addParameter(testRunner.getPath());
File resourceFile = new File(course.getCourseDirectory());
commandLine.addParameter(resourceFile.getPath());
commandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return commandLine.createProcess();
}
}
return null;
}
示例11: setSdkHome
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public void setSdkHome(String sdkHome) {
List<Sdk> sdkList = new ArrayList<Sdk>();
sdkList.add(null);
final List<Sdk> allSdks = PythonSdkType.getAllSdks();
Collections.sort(allSdks, new PreferredSdkComparator());
Sdk selection = null;
for (Sdk sdk : allSdks) {
String homePath = sdk.getHomePath();
if (homePath != null && sdkHome != null && FileUtil.pathsEqual(homePath, sdkHome)) selection = sdk;
sdkList.add(sdk);
}
myInterpreterComboBox.setModel(new CollectionComboBoxModel(sdkList, selection));
}
示例12: actionPerformed
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
Module module = e.getData(LangDataKeys.MODULE);
Sdk sdk = PythonSdkType.findLocalCPython(module);
final SelectFromListDialog selectDialog =
new SelectFromListDialog(project, pythonProcessesList(), new SelectFromListDialog.ToStringAspect() {
public String getToStirng(Object obj) {
PyProcessInfo info = (PyProcessInfo)obj;
return info.getPid() + " " + info.getArgs();
}
}, "Select Python Process", ListSelectionModel.SINGLE_SELECTION);
if (selectDialog.showAndGet()) {
PyProcessInfo process = (PyProcessInfo)selectDialog.getSelection()[0];
PyAttachToProcessDebugRunner runner =
new PyAttachToProcessDebugRunner(project, process.getPid(), sdk.getHomePath());
try {
runner.launch();
}
catch (ExecutionException e1) {
Messages.showErrorDialog(project, e1.getMessage(), "Error Attaching Debugger");
}
;
}
}
示例13: runExternalTool
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
private static String runExternalTool(@NotNull final Module module,
@NotNull final HelperPackage formatter,
@NotNull final String docstring) {
final Sdk sdk = PythonSdkType.findPython2Sdk(module);
if (sdk == null) return null;
final String sdkHome = sdk.getHomePath();
if (sdkHome == null) return null;
final Charset charset = EncodingProjectManager.getInstance(module.getProject()).getDefaultCharset();
final ByteBuffer encoded = charset.encode(docstring);
final byte[] data = new byte[encoded.limit()];
encoded.get(data);
final Map<String, String> env = new HashMap<String, String>();
PythonEnvUtil.setPythonDontWriteBytecode(env);
final GeneralCommandLine commandLine = formatter.newCommandLine(sdkHome, Lists.<String>newArrayList());
LOG.debug("Command for launching docstring formatter: " + commandLine.getCommandLineString());
final ProcessOutput output = PySdkUtil.getProcessOutput(commandLine, new File(sdkHome).getParent(), env, 5000, data, false);
if (!output.checkSuccess(LOG)) {
return null;
}
return output.getStdout();
}
示例14: getInterpreterPath
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
public static String getInterpreterPath(Project project, PythonRunParams config) {
String sdkHome = config.getSdkHome();
if (config.isUseModuleSdk() || StringUtil.isEmpty(sdkHome)) {
Module module = getModule(project, config);
Sdk sdk = PythonSdkType.findPythonSdk(module);
if (sdk == null) return null;
sdkHome = sdk.getHomePath();
}
return sdkHome;
}
示例15: init
import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Override
protected void init() {
if (myHasCompatibleJdk) {
return;
}
String path = null;
File javaDir = myMode.getJavaDir();
if (javaDir != null) {
path = javaDir.getAbsolutePath();
}
if (StringUtil.isEmpty(path)) {
Sdk jdk = IdeSdks.getJdk(FirstRunWizardDefaults.MIN_JDK_VERSION);
if (jdk != null) {
path = jdk.getHomePath();
}
}
if (StringUtil.isEmpty(path)) {
final StringBuilder result = new StringBuilder();
JdkDetection.start(new JdkDetection.JdkDetectionResult() {
@Override
public void onSuccess(String newJdkPath) {
result.append(newJdkPath);
}
@Override
public void onCancel() {
}
});
path = result.toString();
}
if (StringUtil.isEmpty(path)) {
addStep(myJdkLocationStep);
}
else {
myState.put(KEY_JDK_LOCATION, path);
myHasCompatibleJdk = true;
}
}