Search in sources :

Example 1 with ProjectJdkImpl

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

the class PySdkFlavorTest method createMockSdk.

// TODO: Add tests for MayaPy and IronPython SDK flavors
@NotNull
private static Sdk createMockSdk(@NotNull PythonSdkFlavor flavor, @NotNull String versionOutput) {
    final String versionString = flavor.getVersionStringFromOutput(versionOutput);
    final ProjectJdkImpl sdk = new ProjectJdkImpl("Test", PythonSdkType.getInstance(), "/path/to/sdk", versionString);
    sdk.setSdkAdditionalData(new PythonSdkAdditionalData(flavor));
    return sdk;
}
Also used : PythonSdkAdditionalData(com.jetbrains.python.sdk.PythonSdkAdditionalData) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ProjectJdkImpl

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

the class PythonSdkDetailsStep method getVEnvCallback.

@NotNull
private AbstractCreateVirtualEnvDialog.VirtualEnvCallback getVEnvCallback() {
    return new CreateVirtualEnvDialog.VirtualEnvCallback() {

        @Override
        public void virtualEnvCreated(Sdk sdk, boolean associateWithProject) {
            if (associateWithProject) {
                SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
                if (additionalData == null) {
                    additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(sdk.getHomePath()));
                    ((ProjectJdkImpl) sdk).setSdkAdditionalData(additionalData);
                }
                if (myNewProject) {
                    ((PythonSdkAdditionalData) additionalData).associateWithNewProject();
                } else {
                    ((PythonSdkAdditionalData) additionalData).associateWithProject(myProject);
                }
            }
            mySdkAddedCallback.consume(sdk);
        }
    };
}
Also used : ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkAdditionalData(com.intellij.openapi.projectRoots.SdkAdditionalData) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ProjectJdkImpl

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

the class SdkEditor method doSetHomePath.

private void doSetHomePath(final String homePath, final SdkType sdkType) {
    if (homePath == null) {
        return;
    }
    setHomePathValue(homePath.replace('/', File.separatorChar));
    final String newSdkName = suggestSdkName(homePath);
    ((ProjectJdkImpl) mySdk).setName(newSdkName);
    try {
        final Sdk dummySdk = (Sdk) mySdk.clone();
        SdkModificator sdkModificator = dummySdk.getSdkModificator();
        sdkModificator.setHomePath(homePath);
        sdkModificator.removeAllRoots();
        sdkModificator.commitChanges();
        sdkType.setupSdkPaths(dummySdk, mySdkModel);
        clearAllPaths();
        myVersionString = dummySdk.getVersionString();
        if (myVersionString == null) {
            Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", homePath), ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
        }
        sdkModificator = dummySdk.getSdkModificator();
        for (OrderRootType type : myPathEditors.keySet()) {
            SdkPathEditor pathEditor = myPathEditors.get(type);
            pathEditor.setAddBaseDir(dummySdk.getHomeDirectory());
            pathEditor.addPaths(sdkModificator.getRoots(type));
        }
        mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
    } catch (CloneNotSupportedException e) {
        // should not happen in normal program
        LOG.error(e);
    }
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)

Example 4 with ProjectJdkImpl

use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project ballerina by ballerina-lang.

the class BallerinaCodeInsightFixtureTestCase method createMockSdk.

@NotNull
private static Sdk createMockSdk(@NotNull String version) {
    String homePath = new File(getTestDataPath("mockSdk-") + version + "/").getAbsolutePath();
    BallerinaSdkType sdkType = BallerinaSdkType.getInstance();
    ProjectJdkImpl sdk = new ProjectJdkImpl("Ballerina " + version, sdkType, homePath, version);
    sdkType.setupSdkPaths(sdk);
    sdk.setVersionString(version);
    return sdk;
}
Also used : BallerinaSdkType(org.ballerinalang.plugins.idea.sdk.BallerinaSdkType) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ProjectJdkImpl

use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoProjectModelConverterProvider method convertSdks.

private static void convertSdks() {
    ProjectJdkTable sdkTable = ProjectJdkTable.getInstance();
    Collection<String> globalGoPathUrls = ContainerUtil.newLinkedHashSet();
    Collection<Sdk> sdksToDelete = ContainerUtil.newArrayList();
    Collection<Sdk> sdksToAdd = ContainerUtil.newArrayList();
    GoSdkType sdkType = GoSdkType.getInstance();
    for (Sdk sdk : sdkTable.getAllJdks()) {
        String sdkTypeName = sdk.getSdkType().getName();
        if (isGoSdkType(sdkTypeName)) {
            sdksToDelete.add(sdk);
            String sdkHome = sdkType.adjustSelectedSdkHome(sdk.getHomePath());
            if (sdkType.isValidSdkHome(sdkHome)) {
                ProjectJdkImpl newSdk = new ProjectJdkImpl(sdk.getName(), sdkType, sdkHome, sdkType.getVersionString(sdkHome));
                sdkType.setupSdkPaths(newSdk);
                sdksToAdd.add(newSdk);
                for (String classesRoot : sdk.getRootProvider().getUrls(OrderRootType.CLASSES)) {
                    if (!classesRoot.equals(sdk.getHomePath())) {
                        globalGoPathUrls.add(classesRoot);
                    }
                }
            }
        }
    }
    for (VirtualFile file : GoSdkUtil.getGoPathsRootsFromEnvironment()) {
        globalGoPathUrls.remove(file.getUrl());
    }
    AccessToken l = WriteAction.start();
    try {
        for (Sdk sdk : sdksToDelete) {
            sdkTable.removeJdk(sdk);
        }
        for (Sdk sdk : sdksToAdd) {
            sdkTable.addJdk(sdk);
        }
        globalGoPathUrls.addAll(GoApplicationLibrariesService.getInstance().getLibraryRootUrls());
        GoApplicationLibrariesService.getInstance().setLibraryRootUrls(globalGoPathUrls);
    } finally {
        l.finish();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) AccessToken(com.intellij.openapi.application.AccessToken) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) GoSdkType(com.goide.sdk.GoSdkType)

Aggregations

ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)20 Sdk (com.intellij.openapi.projectRoots.Sdk)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)5 File (java.io.File)5 NotNull (org.jetbrains.annotations.NotNull)5 FlexSdkType2 (com.intellij.lang.javascript.flex.sdk.FlexSdkType2)3 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)3 GoSdkType (com.goide.sdk.GoSdkType)2 SdkAdditionalData (com.intellij.openapi.projectRoots.SdkAdditionalData)2 LanguageLevel (com.jetbrains.python.psi.LanguageLevel)2 PythonSdkAdditionalData (com.jetbrains.python.sdk.PythonSdkAdditionalData)2 PythonSdkType (com.jetbrains.python.sdk.PythonSdkType)2 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 AccessToken (com.intellij.openapi.application.AccessToken)1 Application (com.intellij.openapi.application.Application)1 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1