コード例 #1
0
 private void reloadSdk(@NotNull Sdk currentSdk) {
   /* PythonSdkUpdater.update invalidates the modificator so we need to create a new
    one for further changes
   */
   if (PythonSdkUpdater.update(currentSdk, myModificators.get(currentSdk), myProject, null)) {
     myModifiedModificators.remove(myModificators.get(currentSdk));
     myModificators.put(currentSdk, currentSdk.getSdkModificator());
   }
 }
コード例 #2
0
 private void reloadSdk() {
   final Sdk currentSdk = getSelectedSdk();
   if (currentSdk != null) {
     myModifiedModificators.add(myModificators.get(currentSdk));
     reloadSdk(currentSdk);
   }
 }
コード例 #3
0
  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);
      }
    }
  }
コード例 #4
0
  private void editSdk(final Sdk currentSdk) {
    final SdkModificator modificator = myModificators.get(currentSdk);
    final EditSdkDialog dialog =
        new EditSdkDialog(
            myProject,
            modificator,
            s -> {
              if (isDuplicateSdkName(s, currentSdk)) {
                return PyBundle.message("sdk.details.dialog.error.duplicate.name");
              }
              return null;
            });
    if (dialog.showAndGet()) {
      mySdkList.repaint();
      final boolean pathChanged = !Comparing.equal(currentSdk.getHomePath(), dialog.getHomePath());
      if (!modificator.getName().equals(dialog.getName())
          || pathChanged
          || dialog.isAssociateChanged()) {
        myModifiedModificators.add(modificator);
        modificator.setName(dialog.getName());
        modificator.setHomePath(dialog.getHomePath());

        if (dialog.isAssociateChanged()) {
          setSdkAssociated(modificator, dialog.associateWithProject());
        }
        if (pathChanged) {
          reloadSdk(currentSdk);
        }
      }
    }
  }
コード例 #5
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;
    }
  }
コード例 #6
0
 private void editRemoteSdk(Sdk currentSdk) {
   PythonRemoteInterpreterManager remoteInterpreterManager =
       PythonRemoteInterpreterManager.getInstance();
   if (remoteInterpreterManager != null) {
     final SdkModificator modificator = myModificators.get(currentSdk);
     Set<Sdk> existingSdks = Sets.newHashSet(myProjectSdksModel.getSdks());
     existingSdks.remove(currentSdk);
     if (remoteInterpreterManager.editSdk(myProject, modificator, existingSdks)) {
       myModifiedModificators.add(modificator);
     }
   }
 }
コード例 #7
0
 private boolean isDuplicateSdkName(String s, Sdk sdk) {
   for (Sdk existingSdk : myProjectSdksModel.getSdks()) {
     if (existingSdk == sdk) {
       continue;
     }
     String existingName;
     if (myModificators.containsKey(existingSdk)) {
       existingName = myModificators.get(existingSdk).getName();
     } else {
       existingName = existingSdk.getName();
     }
     if (existingName.equals(s)) {
       return true;
     }
   }
   return false;
 }