Search in sources :

Example 6 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 7 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 8 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)

Example 9 with ProjectJdkTable

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

the class JavaTestUtil method setupTestJDK.

public static void setupTestJDK() {
    ApplicationManager.getApplication().runWriteAction(() -> {
        ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
        Sdk jdk = jdkTable.findJdk(TEST_JDK_NAME);
        if (jdk != null) {
            jdkTable.removeJdk(jdk);
        }
        jdkTable.addJdk(getTestJdk());
    });
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 10 with ProjectJdkTable

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

the class AndroidTestCaseHelper method removeExistingAndroidSdks.

public static void removeExistingAndroidSdks() {
    ProjectJdkTable table = ProjectJdkTable.getInstance();
    invokeAndWaitIfNeeded((Runnable) () -> ApplicationManager.getApplication().runWriteAction(() -> {
        for (Sdk sdk : table.getAllJdks()) {
            table.removeJdk(sdk);
        }
        PropertiesComponent component = PropertiesComponent.getInstance(ProjectManager.getInstance().getDefaultProject());
        component.setValue("android.sdk.path", null);
    }));
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Aggregations

ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)17 Sdk (com.intellij.openapi.projectRoots.Sdk)17 ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)5 Nullable (org.jetbrains.annotations.Nullable)5 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)4 FlexSdkType2 (com.intellij.lang.javascript.flex.sdk.FlexSdkType2)3 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)2 Disposable (com.intellij.openapi.Disposable)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)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 FacetUtil (com.intellij.facet.impl.FacetUtil)1 ModuleFileType (com.intellij.ide.highlighter.ModuleFileType)1