Search in sources :

Example 11 with JavaSdk

use of com.intellij.openapi.projectRoots.JavaSdk in project moe-ide-integration by multi-os-engine.

the class MOESdkType method findPotentialJdkPaths.

private static List<File> findPotentialJdkPaths() {
    JavaSdk javaSdk = JavaSdk.getInstance();
    List<String> jdkPaths = Lists.newArrayList(javaSdk.suggestHomePaths());
    String javaHome = SystemProperties.getJavaHome();
    if (javaHome == null || javaHome.isEmpty()) {
        return null;
    }
    jdkPaths.add(javaHome);
    List<File> javaHomePaths = Lists.newArrayListWithCapacity(jdkPaths.size());
    for (String jdkPath : jdkPaths) {
        if (jdkPath == null) {
            continue;
        }
        File javaHomeDir = new File(jdkPath);
        if (javaHomeDir.isDirectory()) {
            javaHomePaths.add(javaHomeDir);
        }
    }
    return javaHomePaths;
}
Also used : JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 12 with JavaSdk

use of com.intellij.openapi.projectRoots.JavaSdk in project moe-ide-integration by multi-os-engine.

the class MOESdkType method getJDK.

public static Sdk getJDK() {
    Sdk sdk = null;
    for (Sdk jdk : ProjectJdkTable.getInstance().getAllJdks()) {
        if (jdk != null && jdk.getSdkType() instanceof JavaSdk) {
            if (sdk == null) {
                sdk = jdk;
            } else {
                JavaSdkVersion version = ((JavaSdk) jdk.getSdkType()).getVersion(jdk);
                JavaSdkVersion desiredVersion = ((JavaSdk) sdk.getSdkType()).getVersion(sdk);
                if (version != null && desiredVersion != null && version.isAtLeast(desiredVersion)) {
                    sdk = jdk;
                }
            }
        }
    }
    return sdk;
}
Also used : JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk)

Aggregations

JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)12 Sdk (com.intellij.openapi.projectRoots.Sdk)10 JavaSdkVersion (com.intellij.openapi.projectRoots.JavaSdkVersion)6 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 AndroidTargetManager (com.android.sdklib.repository.targets.AndroidTargetManager)1 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 CantRunException (com.intellij.execution.CantRunException)1 NamedLibraryElement (com.intellij.ide.projectView.impl.nodes.NamedLibraryElement)1 NamedLibraryElementNode (com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 JavaSdkType (com.intellij.openapi.projectRoots.JavaSdkType)1 ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)1