Search in sources :

Example 51 with ValidationInfo

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;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) IAndroidTarget(com.android.sdklib.IAndroidTarget) ResourceRepository(com.android.ide.common.resources.ResourceRepository) AndroidTargetData(org.jetbrains.android.sdk.AndroidTargetData) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project intellij-plugins by JetBrains.

the class CreateAirDescriptorTemplateDialog method doValidate.

protected ValidationInfo doValidate() {
    final String fileName = myDescriptorFileNameTextField.getText().trim();
    if (fileName.isEmpty()) {
        return new ValidationInfo("Descriptor file name not set", myDescriptorFileNameTextField);
    }
    if (!fileName.toLowerCase().endsWith(".xml")) {
        return new ValidationInfo("Descriptor file name must have xml extension", myDescriptorFileNameTextField);
    }
    final String folderPath = myDescriptorFolderTextWithBrowse.getText().trim();
    if (folderPath.isEmpty()) {
        return new ValidationInfo("Folder is not set", myDescriptorFolderTextWithBrowse);
    }
    final VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(folderPath);
    if (dir != null && !dir.isDirectory()) {
        return new ValidationInfo("Folder for AIR descriptor must be specified", myDescriptorFolderTextWithBrowse);
    }
    final String airVersion = ((String) myAirVersionCombo.getSelectedItem()).trim();
    if (airVersion.isEmpty()) {
        return new ValidationInfo("AIR version is not set", myAirVersionCombo);
    }
    if (!VERSION_PATTERN.matcher(airVersion).matches()) {
        return new ValidationInfo("Incorrect AIR version", myAirVersionCombo);
    }
    final String appId = myAppIdTextField.getText().trim();
    if (appId.isEmpty()) {
        return new ValidationInfo("Application ID is required", myAppIdTextField);
    }
    if (!appId.equals(FlexCommonUtils.fixApplicationId(appId))) {
        return new ValidationInfo("Application ID must contain only following symbols: 0-9, a-z, A-Z, '.', '-'", myAppIdTextField);
    }
    if (myAppNameTextField.getText().trim().isEmpty()) {
        return new ValidationInfo("Application name is required", myAppNameTextField);
    }
    final String appVersion = myAppVersionTextField.getText().trim();
    if (appVersion.isEmpty()) {
        return new ValidationInfo("Application version is not set", myAppVersionTextField);
    }
    if (StringUtil.compareVersionNumbers(airVersion, "2.5") >= 0) {
        if (!VERSION_PATTERN.matcher(appVersion).matches()) {
            return new ValidationInfo("Application version must have following format: [0-999].[0-999].[0-999]", myAppVersionTextField);
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ValidationInfo(com.intellij.openapi.ui.ValidationInfo)

Example 53 with ValidationInfo

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;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) AirSigningOptions(com.intellij.lang.javascript.flex.projectStructure.model.AirSigningOptions)

Aggregations

ValidationInfo (com.intellij.openapi.ui.ValidationInfo)53 Nullable (org.jetbrains.annotations.Nullable)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 File (java.io.File)7 Module (com.intellij.openapi.module.Module)3 Pattern (java.util.regex.Pattern)3 DocumentEvent (javax.swing.event.DocumentEvent)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 ActionButton (com.intellij.openapi.actionSystem.impl.ActionButton)2 Project (com.intellij.openapi.project.Project)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)2 ResourceRepository (com.android.ide.common.resources.ResourceRepository)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 Configuration (com.android.tools.idea.gradle.structure.dependencies.android.Configuration)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)1 PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)1 PsBuildType (com.android.tools.idea.gradle.structure.model.android.PsBuildType)1 PsLibraryAndroidDependency (com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency)1 FilterData (com.android.tools.idea.logcat.PersistentAndroidLogFilters.FilterData)1