mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added detected sdks to create virtual env
This commit is contained in:
+1
-1
@@ -122,7 +122,7 @@ public class PyConfigurableInterpreterList {
|
||||
}
|
||||
|
||||
for (String sdkHome : SdkConfigurationUtil.filterExistingPaths(PythonSdkType.getInstance(), sdkHomes, getModel().getSdks())) {
|
||||
result.add(new PyDetectedSdk(sdkHome, PythonSdkType.getInstance()));
|
||||
result.add(new PyDetectedSdk(sdkHome));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.intellij.facet.ui.FacetEditorValidator;
|
||||
import com.intellij.facet.ui.FacetValidatorsManager;
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -114,6 +116,12 @@ public class CreateVirtualEnvDialog extends IdeaDialog {
|
||||
init();
|
||||
setTitle("Create Virtual Environment");
|
||||
if (suggestedBaseSdk == null && allSdks.size() > 0) {
|
||||
Iterables.removeIf(allSdks, new Predicate<Sdk>() {
|
||||
@Override
|
||||
public boolean apply(Sdk s) {
|
||||
return PythonSdkType.isInvalid(s) || PythonSdkType.isVirtualEnv(s) || RemoteSdkDataHolder.isRemoteSdk(s.getHomePath());
|
||||
}
|
||||
});
|
||||
List<Sdk> sortedSdks = new ArrayList<Sdk>(allSdks);
|
||||
Collections.sort(sortedSdks, new PreferredSdkComparator());
|
||||
suggestedBaseSdk = sortedSdks.get(0);
|
||||
@@ -229,17 +237,7 @@ public class CreateVirtualEnvDialog extends IdeaDialog {
|
||||
|
||||
private void updateSdkList(final List<Sdk> allSdks, @Nullable Sdk initialSelection) {
|
||||
mySdkCombo.setRenderer(new PySdkListCellRenderer());
|
||||
List<Sdk> baseSdks = new ArrayList<Sdk>();
|
||||
for (Sdk s : allSdks) {
|
||||
if (!PythonSdkType.isInvalid(s) && !PythonSdkType.isVirtualEnv(s) && !RemoteSdkDataHolder.isRemoteSdk(s.getHomePath())) {
|
||||
baseSdks.add(s);
|
||||
}
|
||||
else if (s.equals(initialSelection)){
|
||||
initialSelection = null;
|
||||
}
|
||||
}
|
||||
|
||||
mySdkCombo.setModel(new CollectionComboBoxModel(baseSdks, initialSelection));
|
||||
mySdkCombo.setModel(new CollectionComboBoxModel(allSdks, initialSelection));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.projectRoots.SdkTypeId;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
|
||||
|
||||
public class PyDetectedSdk extends ProjectJdkImpl {
|
||||
public PyDetectedSdk(String name, SdkTypeId sdkType) {
|
||||
super(name, sdkType);
|
||||
public PyDetectedSdk(String name) {
|
||||
super(name, PythonSdkType.getInstance());
|
||||
setHomePath(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PythonSdkDetailsStep extends BaseListPopupStep<String> {
|
||||
@@ -148,7 +148,16 @@ public class PythonSdkDetailsStep extends BaseListPopupStep<String> {
|
||||
};
|
||||
|
||||
final CreateVirtualEnvDialog dialog;
|
||||
final List<Sdk> allSdks = Arrays.asList(myExistingSdks);
|
||||
final List<Sdk> allSdks = Lists.newArrayList(myExistingSdks);
|
||||
|
||||
final List<PythonSdkFlavor> flavors = PythonSdkFlavor.getApplicableFlavors(false);
|
||||
for (PythonSdkFlavor flavor : flavors) {
|
||||
final Collection<String> strings = flavor.suggestHomePaths();
|
||||
for (String string : strings) {
|
||||
allSdks.add(new PyDetectedSdk(string));
|
||||
}
|
||||
}
|
||||
|
||||
if (myProject != null) {
|
||||
dialog = new CreateVirtualEnvDialog(myProject, allSdks, null);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ public abstract class PythonSdkFlavor {
|
||||
}
|
||||
|
||||
public static List<PythonSdkFlavor> getApplicableFlavors() {
|
||||
return getApplicableFlavors(true);
|
||||
}
|
||||
|
||||
public static List<PythonSdkFlavor> getApplicableFlavors(boolean addPlatformIndependent) {
|
||||
List<PythonSdkFlavor> result = new ArrayList<PythonSdkFlavor>();
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
@@ -84,7 +88,8 @@ public abstract class PythonSdkFlavor {
|
||||
result.add(UnixPythonSdkFlavor.INSTANCE);
|
||||
}
|
||||
|
||||
result.addAll(getPlatformIndependentFlavors());
|
||||
if (addPlatformIndependent)
|
||||
result.addAll(getPlatformIndependentFlavors());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user