private void removeSdk() { final Sdk currentSdk = getSelectedSdk(); if (currentSdk != null) { final Sdk sdk = myProjectSdksModel.findSdk(currentSdk); final PySdkService sdkService = PySdkService.getInstance(); sdkService.removeSdk(currentSdk); DumbService.allowStartingDumbModeInside( DumbModePermission.MAY_START_MODAL, () -> SdkConfigurationUtil.removeSdk(sdk)); myProjectSdksModel.removeSdk(sdk); myProjectSdksModel.removeSdk(currentSdk); if (myModificators.containsKey(currentSdk)) { SdkModificator modificator = myModificators.get(currentSdk); myModifiedModificators.remove(modificator); myModificators.remove(currentSdk); } refreshSdkList(); mySdkListChanged = true; // TODO select initially selected SDK if (mySdkList.getSelectedIndex() < 0) { mySdkList.setSelectedIndex(0); } } }
private void addCreatedSdk(@Nullable final Sdk sdk, boolean newVirtualEnv) { if (sdk != null) { final PySdkService sdkService = PySdkService.getInstance(); sdkService.restoreSdk(sdk); boolean isVirtualEnv = PythonSdkType.isVirtualEnv(sdk); if (isVirtualEnv && !newVirtualEnv) { AddVEnvOptionsDialog dialog = new AddVEnvOptionsDialog(myMainPanel); dialog.show(); if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) { return; } SdkModificator modificator = myModificators.get(sdk); setSdkAssociated(modificator, !dialog.makeAvailableToAll()); myModifiedModificators.add(modificator); } final Sdk oldSdk = myProjectSdksModel.findSdk(sdk); if (oldSdk == null) { myProjectSdksModel.addSdk(sdk); } refreshSdkList(); mySdkList.setSelectedValue(myProjectSdksModel.findSdk(sdk.getName()), true); mySdkListChanged = true; } }