use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class ScreenRecorderOptionsDialog method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
ValidationInfo info = validateIntegerMultipleOf(myBitRateTextField, 1, "Bit Rate must be an integer.");
if (info != null) {
return info;
}
// MediaEncoder prefers sizes that are multiples of 16 (https://code.google.com/p/android/issues/detail?id=37769).
info = validateIntegerMultipleOf(myWidthTextField, 16, "Width must be an integer.");
if (info != null) {
return info;
}
info = validateIntegerMultipleOf(myHeightTextField, 16, "Height must be an integer.");
if (info != null) {
return info;
}
return super.doValidate();
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class AddLibraryDependencyDialog method doValidate.
@Override
@Nullable
protected ValidationInfo doValidate() {
List<Exception> searchErrors = myLibraryDependenciesForm.getSearchErrors();
if (!searchErrors.isEmpty()) {
StringBuilder buffer = new StringBuilder();
searchErrors.forEach(e -> buffer.append(getErrorMessage(e)).append("\n"));
return new ValidationInfo(buffer.toString(), myLibraryDependenciesForm.getPreferredFocusedComponent());
}
String selectedLibrary = myLibraryDependenciesForm.getSelectedLibrary();
if (isEmpty(selectedLibrary)) {
return new ValidationInfo("Please specify the library to add as dependency", myLibraryDependenciesForm.getPreferredFocusedComponent());
}
PsArtifactDependencySpec spec = PsArtifactDependencySpec.create(selectedLibrary);
PsModule module = getModule();
if (spec != null && module instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) module;
Ref<Boolean> found = new Ref<>(false);
androidModule.forEachDeclaredDependency(dependency -> {
if (dependency instanceof PsLibraryAndroidDependency) {
PsLibraryAndroidDependency libraryDependency = (PsLibraryAndroidDependency) dependency;
PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
if (Objects.equals(spec.group, resolvedSpec.group) && Objects.equals(spec.name, resolvedSpec.name)) {
found.set(true);
}
}
});
if (found.get()) {
String msg = String.format("Library '%1$s' is already a dependency", spec.name);
return new ValidationInfo(msg, myLibraryDependenciesForm.getPreferredFocusedComponent());
}
}
return getScopesPanel().validateInput();
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class AndroidDependencyScopesPanel method validateInput.
@Override
@Nullable
public ValidationInfo validateInput() {
List<Configuration> configurations = myConfigurationsPanel.getSelectedConfigurations();
if (configurations.isEmpty()) {
return new ValidationInfo("Please select at least one configuration", myConfigurationsPanel);
}
List<PsBuildType> buildTypes = myBuildTypesPanel.getSelectedBuildTypes();
if (buildTypes.isEmpty()) {
return new ValidationInfo("Please select at least one build type", myBuildTypesPanel);
}
if (mySelectedScopeNames.isEmpty()) {
if (configurations.size() == 1 && configurations.contains(ANDROID_TEST)) {
boolean hasDebugBuildType = false;
for (PsBuildType buildType : buildTypes) {
if (buildType.getName().equals(DEBUG_BUILD_TYPE)) {
hasDebugBuildType = true;
break;
}
}
if (!hasDebugBuildType) {
return new ValidationInfo("For 'Android Tests', the 'debug' build type must be selected", myBuildTypesPanel);
}
}
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class StateListPicker method doValidate.
/**
* Returns a {@link ValidationInfo} in the case one of the state list state has a value that does not resolve to a valid resource,
* or a value that is a private framework value. or if one of the state list component requires an API level higher than minApi.
*/
@Nullable
public /*if there is no error*/
ValidationInfo doValidate(int minApi) {
IAndroidTarget target = myConfiguration.getRealTarget();
assert target != null;
final AndroidTargetData androidTargetData = AndroidTargetData.getTargetData(target, myModule);
assert androidTargetData != null;
ResourceRepository frameworkResources = myConfiguration.getFrameworkResources();
assert frameworkResources != null;
for (StateComponent component : myStateComponents) {
ValidationInfo error = component.doValidate(minApi, androidTargetData);
if (error != null) {
return error;
}
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project intellij-plugins by JetBrains.
the class KeystorePasswordDialog method doValidate.
protected ValidationInfo doValidate() {
for (Trinity<AirSigningOptions, JPasswordField, JPasswordField> entry : myKeystoresAndPasswordFields) {
final AirSigningOptions signingOptions = entry.first;
final JPasswordField keystorePasswordField = entry.second;
final String keystorePassword = new String(keystorePasswordField.getPassword());
final JPasswordField keyPasswordField = entry.third;
final String keyPassword = keyPasswordField == null ? "" : new String(keyPasswordField.getPassword());
try {
PasswordStore.checkPassword(signingOptions, keystorePassword, keyPassword);
} catch (PasswordStore.SigningOptionsException e) {
final JPasswordField errorField = e.wrongKeyPassword ? keyPasswordField : e.wrongKeystorePassword ? keystorePasswordField : null;
final String message = errorField == null ? PathUtil.getFileName(signingOptions.getKeystorePath()) + ": " + e.getMessage() : e.getMessage();
return new ValidationInfo(message, errorField);
}
}
return null;
}
Aggregations