mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-13328 Create New Project: warning about installing template packages is not shown
This commit is contained in:
+1
-1
@@ -260,7 +260,7 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
||||
}
|
||||
|
||||
public void setWarningText(@Nullable String text) {
|
||||
myErrorLabel.setText("Note: " + text + " ");
|
||||
myErrorLabel.setText("<html>Note: " + text + " </html>");
|
||||
myErrorLabel.setForeground(MessageType.WARNING.getTitleForeground());
|
||||
}
|
||||
|
||||
|
||||
+16
-11
@@ -54,6 +54,7 @@ import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase implements DumbAware {
|
||||
@@ -150,13 +151,7 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase impleme
|
||||
|
||||
final Sdk sdk = getSdk();
|
||||
|
||||
if (myProjectGenerator instanceof PythonProjectGenerator) {
|
||||
final ValidationResult warningResult = ((PythonProjectGenerator)myProjectGenerator).warningValidation(sdk);
|
||||
if (!warningResult.isOk()) {
|
||||
setWarningText(warningResult.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> warningList = new ArrayList<>();
|
||||
final boolean isPy3k = sdk != null && PythonSdkType.getLanguageLevelForSdk(sdk).isPy3K();
|
||||
if (sdk != null && PythonSdkType.isRemote(sdk) && !acceptsRemoteSdk(myProjectGenerator)) {
|
||||
setErrorText("Please choose a local interpreter");
|
||||
@@ -167,7 +162,7 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase impleme
|
||||
String frameworkName = frameworkProjectGenerator.getFrameworkTitle();
|
||||
if (sdk != null && !isFrameworkInstalled(sdk)) {
|
||||
if (PyPackageUtil.packageManagementEnabled(sdk)) {
|
||||
String warningText = frameworkName + " will be installed on the selected interpreter";
|
||||
warningList.add(frameworkName + " will be installed on the selected interpreter");
|
||||
myInstallFramework = true;
|
||||
final PyPackageManager packageManager = PyPackageManager.getInstance(sdk);
|
||||
boolean hasManagement = false;
|
||||
@@ -177,13 +172,23 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase impleme
|
||||
catch (ExecutionException ignored) {
|
||||
}
|
||||
if (!hasManagement) {
|
||||
warningText = "Python packaging tools and " + warningText;
|
||||
warningList.add("Python packaging tools and " + warningList);
|
||||
}
|
||||
setWarningText(warningText);
|
||||
} else {
|
||||
setWarningText(frameworkName + " is not installed on the selected interpreter");
|
||||
warningList.add(frameworkName + " is not installed on the selected interpreter");
|
||||
}
|
||||
}
|
||||
if (myProjectGenerator instanceof PythonProjectGenerator) {
|
||||
final ValidationResult warningResult = ((PythonProjectGenerator)myProjectGenerator).warningValidation(sdk);
|
||||
if (!warningResult.isOk()) {
|
||||
warningList.add(warningResult.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!warningList.isEmpty()) {
|
||||
final String warning = StringUtil.join(warningList, "<br/>");
|
||||
setWarningText(warning);
|
||||
}
|
||||
if (isPy3k && !((PyFrameworkProjectGenerator)myProjectGenerator).supportsPython3()) {
|
||||
setErrorText(frameworkName + " is not supported for the selected interpreter");
|
||||
return false;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
|
||||
@@ -38,7 +39,10 @@ public class PyTemplatesUtil {
|
||||
String templateBinding = null;
|
||||
@NonNls String language = templatesPanel.getTemplateLanguage();
|
||||
if (language != null) {
|
||||
String framework = StringUtil.trimEnd(prefix, '_');
|
||||
framework = StringUtil.trimEnd(framework, '-');
|
||||
String postfix = language.toLowerCase();
|
||||
if (framework.equals(postfix)) return ValidationResult.OK;
|
||||
if (language.equals(TemplatesService.JINJA2)) {
|
||||
postfix = "jinja";
|
||||
}
|
||||
@@ -50,7 +54,7 @@ public class PyTemplatesUtil {
|
||||
try {
|
||||
final PyPackage installedPackage = packageManager.findPackage(templateBinding, false);
|
||||
if (installedPackage == null) {
|
||||
return new ValidationResult(templateBinding + " will be installed on selected interpreter");
|
||||
return new ValidationResult(templateBinding + " will be installed on the selected interpreter");
|
||||
}
|
||||
}
|
||||
catch (ExecutionException ignored) {
|
||||
@@ -61,7 +65,7 @@ public class PyTemplatesUtil {
|
||||
try {
|
||||
final PyPackage installedPackage = packageManager.findPackage(language, false);
|
||||
if (installedPackage == null) {
|
||||
return new ValidationResult(language + " will be installed on selected interpreter");
|
||||
return new ValidationResult(language + " will be installed on the selected interpreter");
|
||||
}
|
||||
}
|
||||
catch (ExecutionException ignored) {
|
||||
|
||||
Reference in New Issue
Block a user