Search in sources :

Example 16 with PythonSdkFlavor

use of com.jetbrains.python.sdk.flavors.PythonSdkFlavor in project intellij-community by JetBrains.

the class PythonSdkDetailsStep method createVirtualEnvSdk.

private void createVirtualEnvSdk() {
    AbstractCreateVirtualEnvDialog.VirtualEnvCallback callback = getVEnvCallback();
    final CreateVirtualEnvDialog dialog;
    final List<Sdk> allSdks = Lists.newArrayList(myExistingSdks);
    Iterables.removeIf(allSdks, new Predicate<Sdk>() {

        @Override
        public boolean apply(Sdk sdk) {
            return !(sdk.getSdkType() instanceof PythonSdkType);
        }
    });
    final List<PythonSdkFlavor> flavors = PythonSdkFlavor.getApplicableFlavors(false);
    for (PythonSdkFlavor flavor : flavors) {
        final Collection<String> strings = flavor.suggestHomePaths();
        for (String string : SdkConfigurationUtil.filterExistingPaths(PythonSdkType.getInstance(), strings, myExistingSdks)) {
            allSdks.add(new PyDetectedSdk(string));
        }
    }
    if (myProject != null) {
        dialog = new CreateVirtualEnvDialog(myProject, allSdks);
    } else {
        dialog = new CreateVirtualEnvDialog(myOwnerComponent, allSdks);
    }
    if (dialog.showAndGet()) {
        dialog.createVirtualEnv(callback);
    }
}
Also used : PythonSdkFlavor(com.jetbrains.python.sdk.flavors.PythonSdkFlavor) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 17 with PythonSdkFlavor

use of com.jetbrains.python.sdk.flavors.PythonSdkFlavor in project intellij-community by JetBrains.

the class PythonSdkType method sdkPath.

@Override
public String sdkPath(@NotNull VirtualFile homePath) {
    String path = super.sdkPath(homePath);
    PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(path);
    if (flavor != null) {
        VirtualFile sdkPath = flavor.getSdkPath(homePath);
        if (sdkPath != null) {
            return FileUtil.toSystemDependentName(sdkPath.getPath());
        }
    }
    return FileUtil.toSystemDependentName(path);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CPythonSdkFlavor(com.jetbrains.python.sdk.flavors.CPythonSdkFlavor) PythonSdkFlavor(com.jetbrains.python.sdk.flavors.PythonSdkFlavor)

Example 18 with PythonSdkFlavor

use of com.jetbrains.python.sdk.flavors.PythonSdkFlavor in project intellij-community by JetBrains.

the class PySdkListCellRenderer method customize.

@Override
public void customize(JList list, Object item, int index, boolean selected, boolean hasFocus) {
    if (item instanceof Sdk) {
        Sdk sdk = (Sdk) item;
        final PythonSdkFlavor flavor = PythonSdkFlavor.getPlatformIndependentFlavor(sdk.getHomePath());
        final Icon icon = flavor != null ? flavor.getIcon() : ((SdkType) sdk.getSdkType()).getIcon();
        String name;
        if (mySdkModifiers != null && mySdkModifiers.containsKey(sdk)) {
            name = mySdkModifiers.get(sdk).getName();
        } else {
            name = sdk.getName();
        }
        if (name.startsWith("Remote")) {
            final String trimmedRemote = StringUtil.trim(name.substring("Remote".length()));
            if (!trimmedRemote.isEmpty())
                name = trimmedRemote;
        }
        final String flavorName = flavor == null ? "Python" : flavor.getName();
        if (name.startsWith(flavorName))
            name = StringUtil.trim(name.substring(flavorName.length()));
        if (isShortVersion) {
            name = shortenName(name);
        }
        if (PythonSdkType.isInvalid(sdk)) {
            setText("[invalid] " + name);
            setIcon(wrapIconWithWarningDecorator(icon));
        } else if (PythonSdkType.isIncompleteRemote(sdk)) {
            setText("[incomplete] " + name);
            setIcon(wrapIconWithWarningDecorator(icon));
        } else if (PythonSdkType.hasInvalidRemoteCredentials(sdk)) {
            setText("[invalid] " + name);
            setIcon(wrapIconWithWarningDecorator(icon));
        } else if (sdk instanceof PyDetectedSdk) {
            setText(name);
            setIcon(IconLoader.getTransparentIcon(icon));
        } else {
            setText(name);
            setIcon(icon);
        }
    } else if (SEPARATOR.equals(item))
        setSeparator();
    else if (item == null)
        setText(myNullText);
}
Also used : PythonSdkFlavor(com.jetbrains.python.sdk.flavors.PythonSdkFlavor) Sdk(com.intellij.openapi.projectRoots.Sdk) LayeredIcon(com.intellij.ui.LayeredIcon)

Aggregations

PythonSdkFlavor (com.jetbrains.python.sdk.flavors.PythonSdkFlavor)18 Sdk (com.intellij.openapi.projectRoots.Sdk)9 UnixPythonSdkFlavor (com.jetbrains.python.sdk.flavors.UnixPythonSdkFlavor)6 CPythonSdkFlavor (com.jetbrains.python.sdk.flavors.CPythonSdkFlavor)4 LanguageLevel (com.jetbrains.python.psi.LanguageLevel)2 Nullable (org.jetbrains.annotations.Nullable)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LayeredIcon (com.intellij.ui.LayeredIcon)1 Course (com.jetbrains.edu.learning.courseFormat.Course)1 CommandLinePatcher (com.jetbrains.python.run.CommandLinePatcher)1 PyDetectedSdk (com.jetbrains.python.sdk.PyDetectedSdk)1 IronPythonSdkFlavor (com.jetbrains.python.sdk.flavors.IronPythonSdkFlavor)1 JythonSdkFlavor (com.jetbrains.python.sdk.flavors.JythonSdkFlavor)1 VirtualEnvSdkFlavor (com.jetbrains.python.sdk.flavors.VirtualEnvSdkFlavor)1 AbstractPythonLegacyTestRunConfiguration (com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration)1 ArrayList (java.util.ArrayList)1 NonNls (org.jetbrains.annotations.NonNls)1