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);
}
}
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);
}
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);
}
Aggregations