Search in sources :

Example 1 with ProjectJdkTable

use of com.intellij.openapi.projectRoots.ProjectJdkTable in project intellij-plugins by JetBrains.

the class FlexTestUtils method doSetupFlexSdk.

public static void doSetupFlexSdk(final Module module, final String flexSdkRootPath, final boolean air, final String sdkVersion) {
    WriteAction.run(() -> {
        final Sdk sdk = createSdk(flexSdkRootPath, sdkVersion);
        if (ModuleType.get(module) == FlexModuleType.getInstance()) {
            modifyBuildConfiguration(module, bc -> {
                bc.setNature(new BuildConfigurationNature(air ? TargetPlatform.Desktop : TargetPlatform.Web, false, OutputType.Application));
                bc.getDependencies().setSdkEntry(Factory.createSdkEntry(sdk.getName()));
            });
        }
        Disposer.register(module, new Disposable() {

            @Override
            public void dispose() {
                WriteAction.run(() -> {
                    final ProjectJdkTable projectJdkTable = ProjectJdkTable.getInstance();
                    projectJdkTable.removeJdk(sdk);
                });
            }
        });
    });
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) Disposable(com.intellij.openapi.Disposable) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 2 with ProjectJdkTable

use of com.intellij.openapi.projectRoots.ProjectJdkTable in project android by JetBrains.

the class AndroidSdkAdditionalData method getJavaSdk.

@Nullable
public Sdk getJavaSdk() {
    final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
    if (myJavaSdk == null) {
        if (myJavaSdkName != null) {
            myJavaSdk = jdkTable.findJdk(myJavaSdkName);
            myJavaSdkName = null;
        } else {
            for (Sdk jdk : jdkTable.getAllJdks()) {
                if (Jdks.getInstance().isApplicableJdk(jdk)) {
                    myJavaSdk = jdk;
                    break;
                }
            }
        }
    }
    return myJavaSdk;
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ProjectJdkTable

use of com.intellij.openapi.projectRoots.ProjectJdkTable in project intellij-community by JetBrains.

the class Sandbox method getJavaSdk.

@Nullable
public Sdk getJavaSdk() {
    final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
    if (myJavaSdk == null) {
        if (myJavaSdkName != null) {
            myJavaSdk = jdkTable.findJdk(myJavaSdkName);
            myJavaSdkName = null;
        } else {
            for (Sdk jdk : jdkTable.getAllJdks()) {
                if (IdeaJdk.isValidInternalJdk(myCurrentJdk, jdk)) {
                    myJavaSdk = jdk;
                    break;
                }
            }
        }
    }
    return myJavaSdk;
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ProjectJdkTable

use of com.intellij.openapi.projectRoots.ProjectJdkTable in project android by JetBrains.

the class AndroidManifestDomTest method doTestSdkVersionAttributeValueCompletion.

private void doTestSdkVersionAttributeValueCompletion() throws Throwable {
    final ProjectJdkTable projectJdkTable = ProjectJdkTable.getInstance();
    final Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk();
    ApplicationManager.getApplication().runWriteAction(() -> projectJdkTable.addJdk(sdk, getTestRootDisposable()));
    doTestCompletionVariants(getTestName(true) + ".xml", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25");
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 5 with ProjectJdkTable

use of com.intellij.openapi.projectRoots.ProjectJdkTable in project intellij-plugins by JetBrains.

the class FlexSdkUtils method createOrGetSdk.

@Nullable
public static Sdk createOrGetSdk(final SdkType sdkType, final String path) {
    // todo work with sdk modifiable model if Project Structure is open!
    final VirtualFile sdkHome = path == null ? null : LocalFileSystem.getInstance().findFileByPath(path);
    if (sdkHome == null)
        return null;
    final ProjectJdkTable projectJdkTable = ProjectJdkTable.getInstance();
    for (final Sdk flexSdk : projectJdkTable.getSdksOfType(sdkType)) {
        final String existingHome = flexSdk.getHomePath();
        if (existingHome != null && sdkHome.getPath().equals(FileUtil.toSystemIndependentName(existingHome))) {
            if (sdkType instanceof FlexmojosSdkType) {
                final SdkAdditionalData data = flexSdk.getSdkAdditionalData();
                if (data == null || ((FlexmojosSdkAdditionalData) data).getFlexCompilerClasspath().isEmpty()) {
                    sdkType.setupSdkPaths(flexSdk);
                }
            }
            return flexSdk;
        }
    }
    return createSdk(sdkType, sdkHome.getPath());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkAdditionalData(com.intellij.openapi.projectRoots.SdkAdditionalData) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)21 Sdk (com.intellij.openapi.projectRoots.Sdk)21 Nullable (org.jetbrains.annotations.Nullable)7 ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)5 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 FlexSdkType2 (com.intellij.lang.javascript.flex.sdk.FlexSdkType2)3 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)3 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)2 Disposable (com.intellij.openapi.Disposable)2 File (java.io.File)2 Container (aQute.bnd.build.Container)1 Project (aQute.bnd.build.Project)1 Workspace (aQute.bnd.build.Workspace)1 Attrs (aQute.bnd.header.Attrs)1 Refreshable (aQute.bnd.service.Refreshable)1 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 GoSdkType (com.goide.sdk.GoSdkType)1 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1 JavacConfiguration (com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration)1