use of com.intellij.facet.ui.ValidationResult in project intellij-community by JetBrains.
the class PyStudyDirectoryProjectGenerator method validate.
@NotNull
@Override
public ValidationResult validate(@NotNull String s) {
final Project project = ProjectManager.getInstance().getDefaultProject();
final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
if (sdks.isEmpty()) {
myValidationResult = new ValidationResult(NO_PYTHON_INTERPRETER);
}
return myValidationResult;
}
use of com.intellij.facet.ui.ValidationResult in project intellij-community by JetBrains.
the class TemplateProjectDirectoryGenerator method validate.
@NotNull
@Override
public ValidationResult validate(@NotNull String baseDirPath) {
String message = "Invalid settings";
for (WizardInputField field : myTemplate.getInputFields()) {
try {
if (field.validate()) {
continue;
}
} catch (ConfigurationException e) {
message = e.getMessage();
}
return new ValidationResult(message);
}
ValidationResult result = myTemplate.validate(baseDirPath);
if (result != null) {
return result;
}
return ValidationResult.OK;
}
use of com.intellij.facet.ui.ValidationResult in project intellij-community by JetBrains.
the class ProjectSettingsStepBase method checkValid.
public boolean checkValid() {
if (myLocationField == null)
return true;
final String projectName = myLocationField.getText();
setErrorText(null);
if (projectName.trim().isEmpty()) {
setErrorText("Project name can't be empty");
return false;
}
if (myLocationField.getText().indexOf('$') >= 0) {
setErrorText("Project directory name must not contain the $ character");
return false;
}
if (myProjectGenerator != null) {
final String baseDirPath = myLocationField.getTextField().getText();
ValidationResult validationResult = myProjectGenerator.validate(baseDirPath);
if (!validationResult.isOk()) {
setErrorText(validationResult.getErrorMessage());
return false;
}
if (myProjectGenerator instanceof WebProjectTemplate) {
final WebProjectGenerator.GeneratorPeer peer = ((WebProjectTemplate) myProjectGenerator).getPeer();
final ValidationInfo validationInfo = peer.validate();
if (validationInfo != null) {
setErrorText(validationInfo.message);
return false;
}
}
}
return true;
}
use of com.intellij.facet.ui.ValidationResult in project intellij-community by JetBrains.
the class FacetLibrariesValidatorImpl method check.
@NotNull
public ValidationResult check() {
if (myRequiredLibraries == null) {
return ValidationResult.OK;
}
List<VirtualFile> roots = collectRoots(myContext.getRootModel());
RequiredLibrariesInfo.RequiredClassesNotFoundInfo info = myRequiredLibraries.checkLibraries(VfsUtil.toVirtualFileArray(roots));
if (info == null) {
return ValidationResult.OK;
}
String missingJars = IdeBundle.message("label.missed.libraries.prefix") + " " + info.getMissingJarsText();
LibraryInfo[] missingLibraries = info.getLibraryInfos();
CustomLibraryDescription description = new OldCustomLibraryDescription(missingLibraries, myDescription.getDefaultLibraryName());
return new ValidationResult(missingJars, new LibrariesQuickFix(description));
}
use of com.intellij.facet.ui.ValidationResult in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method checkValid.
@Override
public boolean checkValid() {
myInstallFramework = false;
if (!super.checkValid()) {
return false;
}
if (myProjectGenerator instanceof PythonProjectGenerator) {
final Sdk sdk = getSdk();
if (sdk == null) {
if (!((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
setErrorText("No Python interpreter selected");
return false;
}
return true;
}
if (PythonSdkType.isInvalid(sdk)) {
setErrorText("Choose valid python interpreter");
return false;
}
final List<String> warningList = new ArrayList<>();
final boolean isPy3k = PythonSdkType.getLanguageLevelForSdk(sdk).isPy3K();
try {
acceptsSdk(myProjectGenerator, sdk, new File(myLocationField.getText()));
} catch (final PythonProjectGenerator.PyNoProjectAllowedOnSdkException e) {
setErrorText(e.getMessage());
return false;
}
if (myRemotePathRequired && StringUtil.isEmpty(myRemotePathField.getTextField().getText())) {
setErrorText("Remote path not provided");
return false;
}
if (myProjectGenerator instanceof PyFrameworkProjectGenerator) {
PyFrameworkProjectGenerator frameworkProjectGenerator = (PyFrameworkProjectGenerator) myProjectGenerator;
String frameworkName = frameworkProjectGenerator.getFrameworkTitle();
if (!isFrameworkInstalled(sdk)) {
if (PyPackageUtil.packageManagementEnabled(sdk)) {
myInstallFramework = true;
final List<PyPackage> packages = PyPackageUtil.refreshAndGetPackagesModally(sdk);
if (packages == null) {
warningList.add(frameworkName + " will be installed on the selected interpreter");
return false;
}
if (!PyPackageUtil.hasManagement(packages)) {
warningList.add("Python packaging tools and " + frameworkName + " will be installed on the selected interpreter");
} else {
warningList.add(frameworkName + " will be installed on the selected interpreter");
}
} else {
warningList.add(frameworkName + " is not installed on the selected interpreter");
}
}
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;
}
}
}
return true;
}
Aggregations